Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the Person class that we developed previously. Write a class called Stu

ID: 3702668 • Letter: C

Question

Consider the Person class that we developed previously. Write a class called Student class. The student class extends the Person class and it contains An additional instance variable named program (of type String) . A constructor that creates a student instance with the given parameters. .Getters and setters for instance variable(s). . A toString0 that returns a short description of the instance. Write the Student class in the answer box below assuming that the Person class has been done for you. Note - keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks For example: Test Result Student s new Student ("Jimmy", 21, "Information Technology System.out.println(s); Student [Jimmy (21), Information Technology] Answer (penalty regime, 0 %)

Explanation / Answer


public class Person {

   protected String name;
   protected int age ;
  
   public Person(String name, int age) {
       this.name = name;
       this.age = age;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public int getAge() {
       return age;
   }

   public void setAge(int age) {
       this.age = age;
   }

   @Override
   public String toString() {
       return name + "("+age + ")";
   }
  
}

Student.java


public class Student extends Person {

   private String program;

   public Student(String name, int age, String program) {
       super(name, age);
       this.program = program;
   }

   public String getProgram() {
       return program;
   }

   public void setProgram(String program) {
       this.program = program;
   }

   @Override
   public String toString() {
       return "Student [" + super.toString() + " , " + program + "]";
   }

   public static void main(String[] args) {
       Student s = new Student("Jimmy", 21, "Information Technology");
       System.out.println(s);
   }
}

Output:

Student [Jimmy(21) , Information Technology]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote