Question 1 of 25
Hints left: 3
Q1
Which of this keyword must be used to inherit a class?
Q2
What will be the output of the following Java code? class A { public int i; protected int j; } class B extends A { int j; void display() { super.j = 3; System.out.println(i + " " + j); } } class Output { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
Q3
Static members are not inherited to subclass.
Q4
What will be the output of the following Java code? class Output { public static void main(String args[]) { Object obj = new Object(); System.out.print(obj.getclass()); } }
Q5
What will be the output of the following Java program? class A { int i; int j; A() { i = 1; j = 2; } } class Output { public static void main(String args[]) { A obj1 = new A(); A obj2 = new A(); System.out.print(obj1.equals(obj2)); } }
Q6
Which of these keywords can be used to prevent inheritance of a class?
Q7
In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
Q8
Which of these is not abstract?
Q9
What will be the output of the following Java program? class A { int i; void display() { System.out.println(i); } } class B extends A { int j; void display() { System.out.println(j); } } class inheritance_demo { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
Q10
Does Java support multiple level inheritance?
Q11
What would be the result if a class extends two interfaces and both have a method with same name and signature? Lets assume that the class is not implementing that method.
Q12
Which of these is not a correct statement?
Q13
Which of these class is superclass of every class in Java?
Q14
Which of these class relies upon its subclasses for complete implementation of its methods?
Q15
What will be the output of the following Java program? class A { int i; } class B extends A { int j; void display() { super.i = j + 1; System.out.println(j + " " + i); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
Q16
Which of these is correct way of inheriting class A by class B?
Q17
Which of the following is used for implementing inheritance through class?
Q18
Which of these keywords cannot be used for a class which has been declared final?
Q19
What will be the output of the following Java code? class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
Q20
Which of the following is used for implementing inheritance through an interface?
Q21
What will be the output of the following Java code? class A { int i; int j; A() { i = 1; j = 2; } } class Output { public static void main(String args[]) { A obj1 = new A(); System.out.print(obj1.toString()); } }
Q22
What is not type of inheritance?
Q23
Which of these keywords are used to define an abstract class?
Q24
Which of these packages contains abstract keyword?
Q25
What will be the output of the following Java program? class A { public int i; public int j; A() { i = 1; j = 2; } } class B extends A { int a; B() { super(); } } class super_use { public static void main(String args[]) { B obj = new B(); System.out.println(obj.i + " " + obj.j) } }