Question 10
Consider the code given below.
interface Shape { public abstract double getArea();}class Rectangle implements Shape, Cloneable { protected double width; protected double height; public Rectangle(double w, double h) width = w; height = h; } public double getArea() { return width * height; } public Rectangle clone() throws CloneNotSupportedException { return (Rectangle) super.clone(); }}class Square extends Rectangle { public Square(double side) { super(side, side); } public Square clone() throws CloneNotSupportedException { return (Square) super.clone(); }}public class ShapeTest { public static void main(String[] args) { try { Square s1 = new Square(5); Square s2 = s1.clone(); s1.width = 10; System.out.print(s1.getArea() + s2.getArea()); } catch (CloneNotSupportedException e) { System.out.println("Cloning not supported"); } }}What will the output be?
125.0
75.0
50.0
Cloning not supported