Qtr No. 213, New Town Yehlanka Indore 454775
What is the output of the following code?
interface Test {
void display();
}
class Figure implements Test {
public void display()//line 1
{
System.out.println("Inside class Figure");
}
}
public class ChildFigure extends Figure {//line 2
public void display() {
System.out.println("Inside class ChildFigure");
}
public static void main(String args[]) {
Test ref = new ChildFigure();
ref.display();
Figure obj = (Figure) ref;//line 3
obj.display();
}
}
Compilation error at line 1 as display() methods can't be public
Compilation error at line 2 as class ChildFigure must implement Test interface
Compilation error at line 3 as Test ref can't be converted into Figure type class
Will print 'Inside class ChildFigure ' and 'Inside class ChildFigure' respectively
To get all Infosys Certified Java Programmer Exam questions Join Group https://bit.ly/infy_premium_group
We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.
Qtr No. 213, New Town Yehlanka Indore 454775
admin@prepflix.in