JAVA Overriding and Overloading
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)); }}

Runtime error
Will not compile.
Will compile and run printing out 20
Will compile and run printing out 25

ANSWER DOWNLOAD EXAMIANS APP

JAVA Overriding and Overloading
what is the result of the following piece of code:public class Person{ public void talk(){ System.out.print("I am a Person"); }}public class Student extends Person{ public void talk(){ System.out.print("I am a Student"); }}public class Test{ public static void main(String args[]){ Person p = new Student(); p.talk(); }}

I am a Person
I am a Student I am a Person
I am a Person I am a Student
I am a Student

ANSWER DOWNLOAD EXAMIANS APP

JAVA Overriding and Overloading
What is the output for the below code ?class A{ private void printName(){ System.out.println("Value-A"); }}class B extends A{ public void printName(){ System.out.println("Name-B"); }}public class Test{ public static void main (String[] args){ B b = new B(); b.printName(); }}

Name-B
None of these
Value-A Name-B
Value-A
Compilation fails - private methods can't be override

ANSWER DOWNLOAD EXAMIANS APP