Java SE 8 Programmer II Practice Questions

Next

1. Given the following code  :-

1     class base1
2     {
3     void display()
4     {
5     System.out.println("base display");
6     }
7     }
8
9     class student extends base1
10     {
11     void display()
12     {
13     System.out.println("student display");
14     }
15
16     void details()
17     {
18     System.out.println("student details");
19     }
20     }
21
22     public class teacher extends student
23     {
24     void display()
25     {
26     System.out.println("teacher display");
27     }
28
29     public void details()
30     {
31     System.out.println("teacher details");
32     }
33     public static void main(String args[])
34     {
35     student s1=new student();
36     s1.details();
37     teacher t=new teacher();
38     t.details();
39     s1=t;
40     s1.details();
41     base1 b1=new base1();
42     b1=s1;
43     b1.display();
44     b1.details();
45     }
46     }

What is the output on execution of the above program?
student details teacher details student details base display student details

student details teacher details teacher details teacher display student details

student details teacher details student display teacher display teacher details

compilation error



Your Answer =


Answer / Explanation:

CertExams Blog!  Certexams.com Facebook Page Certexams.com Twitter Page Certexams on YouTube 


Cert-Ex™ Exam Simulators, Cert-Ex™ Network Simulator, Cert-Ex™ Cheatsheets are written independently by CertExams.com and not affiliated or authorized by respective certification providers. Cert-Ex™ is a trade mark of CertExams.com or entity representing Certexams.com.Java™ is a trademark of Oracle® Corporation