Question: Pesron class public abstract class Person { private String name; private String address; private short age; // constructor that takes only two paras public Person(String
Pesron class public abstract class Person { private String name; private String address; private short age; // constructor that takes only two paras public Person(String name, short age) { super(); this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public abstract String getAddress() ; public abstract void setAddress(String address); public short getAge() { return age; } public void setAge(short age) { this.age = age; } }
| public class DriverClass { | |
| public static void main(String[] args) { | |
| // ToDo 5: Fix the error | |
| // ToDo 6: Fix the constructor of Student class | |
| // ToDo 7: Add a toString method for Student class | |
| Student std1= new Student("James", 20); | |
| // ToDo 8: Set the gpa of the student using the scanner and user | |
| // input and then print the output. | |
| System.out.println(std1); | |
| // ToDo 9: add comments and explain your code | |
| // ToDo 10: submit using a pull request. | |
| } | |
| } |
| public class Student { | |
| // ToDo 1: Make this class a child of Person | |
| // ToDo 2: Fix the resulting errors | |
| // ToDo 3: Add a field for GPA and create setter and getter | |
| // ToDo 4: Add comments to your code | |
| } |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
