Q74
What will be the output of the following Java code snippet? public class Shape public int area() return 1; public class Rectangle extends Shape public int area() return 3; class Main() public static void main(String[] args) Shape shape = new Shape(); Rectangle rect = new Rectangle(); shape = rect; System.out.println(shape.area());
A.
Compilation failure
B.
3
AnswerC.
1
D.
2
Answer: Option B
Solution
Answer: Option B
No explanation is given for this question Let's Discuss on Board