1.

What is the outcome of below code SquareExample class?
class Shape 
{
public int area()
{
return 2;
}
}

class Square extends Shape
{
public int area()
{
return 7;
}
}

public class SquareExample
{
public static void main(String[] args)
{
Shape obj = new Shape();
Square obj0 = new Square();
obj0 = obj;
System.out.println(obj0.area());
}
}

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


Discussion

No Comment Found

Related MCQs