Single Choice Not Set

QWhat 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));
      }
}

 

ID: #2239 Overriding and Overloading in Java 1,525 views
Question Info
#2239Q ID
Not SetDifficulty
Overriding and Overloading in JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Will not compile.
  • B Will compile and run printing out 20
  • C Runtime error
  • D Will compile and run printing out 25
Correct Answer

Explanation

Will compile and run printing out 20

Share This Question

Challenge a friend or share with your study group.