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 .  Runtime error
B .  Will compile and run printing out 20
C .  Will not compile.
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 *

Latest Videos

Latest Test Papers