Sail E0 Webinar
Question
What will be the output of the following program code?
class Rectangle{
public int area(int length, int width){
return length*width;
}
}
class Square extends Rectangle{
public int area(long length, long width){
return (int) Math.pow(length, 2);
}
}
public class Test{
public static void main(String args[]){
Square r = new Square();
System.out.println(r.area(5 , 4));
}
}
Options:
A .  Will not compile.
B .  Will compile and run printing out 20
C .  Runtime error
D .  Will compile and run printing out 25
Answer: Option B

Submit Your Solution Below and Earn Points !
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

More Questions on This Topic :


Latest Videos

Latest Test Papers