Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 dataStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started