1.

What is the outcome of below code Box class?class Shape { public int area() { return 1; }}class Square extends Shape { public int area() { return 2; }}class Rectangle extends Shape { public int area() { return 3; }}public class Box{ public static void main(String[] args) { Shape obj = new Shape(); Square obj0 = new Square(); Rectangle obj1 = new Rectangle(); obj1 = (Rectangle)obj0; System.out.println(obj0.area()); }}

A. Compilation Error
B. Runtime Error
C. Default Value
D. All of above
E. None of these
Answer» B. Runtime Error


Discussion

No Comment Found

Related MCQs