Answered You can hire a professional tutor to get the answer.

QUESTION

1. (100 marks) What is the output produced by the program below?

1. (100 marks) What is the output produced by the program below?public class Rectangle{private double length;private double width;public Rectangle(double l, double w){length = l;width = w;}public double area() { return width*length; }public static void main(String [] args){Rectangle r = new Rectangle(1, 2); // first object instantiationSystem.out.println(r);System.out.println("Area=" + r.area());r = new Rectangle(2, 5); // second object instantiationSystem.out.println(r);System.out.println("Area=" + r.area());}}Discussion:• How many reference variables are there in the program?• What do you think are the two components of a reference value?• Is it possible to make use of the first Rectangle object instance (length=1 and width=2)again after the line “second ob ject instan tiation”?

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question