Description
Consider the following class: public class Human{ public int age; public double height; }
Find the output of the following sequence of statements.
Then verify the output by writing a HumanTester class with following codes inside the main method.
Human h1 = new Human(); Output
Human h2 = new Human(); h1.age = 21; h1.height = 5.5;
System.out.println(h1.age);
System.out.println(h1.height); h2.height = h1.height – 3; System.out.println(h2.height); h2.age = h1.age++;
System.out.println(h1.age);
h2 = h1;
System.out.println(h2.age);
System.out.println(h2.height);
h2.age++; h2.height++;
System.out.println(h1.age);
System.out.println(h1.height); h1.age = ++h2.age;
System.out.println(h2.age);
System.out.println(h2.height);
Task1 Human – Page 1 of 1
Reviews
There are no reviews yet.