Question: Q2)Write a java program Q2. Write a program Define a class name Person with the following specifications: a) A private variable name of type String.

Q2)Write a java program

Q2)Write a java program Q2. Write a program Define a class name

Q2. Write a program Define a class name Person with the following specifications: a) A private variable name of type String. b) A private variable age of type int. c) A zero-parameterized constructor to initialize all the variables to default. d) A full parameterized constructor to initialize the variables. e) A public method to String to return the person data. Define another class name Student which is extended form Person with the following specifications: a) A private variable gpa of type double. b) A zero-parameterized constructor which calls super class zero-parameter constructor, and also initializes gpa to zero. c) A full parameterized constructor which calls the super class parameterized constructor and initialize all the variables. d) A setter and getter method for gpa variable. e) A public method toString to return the student data, this method should call the toString method from the supper class. Check the functionality in main class by instantiating an array of objects of the class Student, calling both the forms of constructor of subclass, ask the user to enter a student gpa and store it, and print all students data

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!