MCQOPTIONS
Saved Bookmarks
| 1. |
What is the outcome of below code Output class?class Shape { public int area() { return 2; }}class Square extends Shape { public int area() { return 5; }}class Rectangle extends Shape { public int area() { return 7; }}public class Output{ public static void main(String[] args) { Shape obj = new Shape(); Square obj0 = new Square(); Rectangle obj1 = new Rectangle(); obj1 = (Rectangle)obj; System.out.println(obj0.area()); }} |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | Default value |
| D. | 7 |
| E. | 5 |
| Answer» C. Default value | |