Java Constructor
class Add
{
int add (int x , int y)
{
return (x+y);
}
}
class FloatAdd extends Add
{
float add(float x, float y)
{
return (x+y);
}
}
class Test
{
public static void main(String [] args)
{
Add a = new Add();
FloatAdd addObj = (FloatAdd) a;
System.out.println("Result : "+addObj.add(10, 20));
}
}
What would be output?
Options
- 30.00
- 30
- Complie error
- Runtime Exception
CORRECT ANSWER : Complie error
Write your comments