Question: //In Mamma1.java class Mamma1 { private int age; private double weight; Mamma1 ( float weight, int age) { this.age = age; this.weight = weight; }
//In Mamma1.java
class Mamma1
{
private int age;
private double weight;
Mamma1 ( float weight, int age)
{
this.age = age;
this.weight = weight;
}
public float getWeight ()
{
return weight;
}
public int getAge ()
{
return age;
}
}
. Write a client class called Lab4.java
.Create an object of class student called alex whose major is CS,gpa is 3.4, credit hours =54, height is170 cm , weight is 179 pounds and age is 18.
.Create an object of class Doctor called jack whose specialty is "Dermatology", years =4, height is 173 cm, weight is 179 pounds and age is 40.
.Print out the student's major, gpa, year , and age
.Print out the doctor's specialty, height, weight, and salary
.What will be the output after you execute the following statements? Explain you answer
Mamma1 mam1 = jack;
System.out.println(Mam1.getSalary());
. What will be the output after you execute the following statements? Explain your answer
Human hum1=alex;
System.out.println(Hum1.getHeight());
. what will be the output after you execute the following statements?Explain your answer
Mammal1 Mam1=jack;
System.out.println(Mam1.getWeight());
.What will be the output after you execute the following statements? Explain your answer
Mamma1 mam1=jack;
System.out.println((Human)Mam1).getHeight());
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
