Question 1 of 25
Hints left: 3
Q1
Which of these is correct way of inheriting class A by class B?
Q2
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(); } }
Q3
Which of the following is used for implementing inheritance through an interface?
Q4
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(); } }
Q5
Which of the following is used for implementing inheritance through class?
Q6
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)); } }
Q7
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()); } }
Q8
Which of these keywords can be used to prevent inheritance of a class?
Q9
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(); } }
Q10
Does Java support multiple level inheritance?
Q11
What is not type of inheritance?
Q12
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) } }
Q13
Which of these keywords are used to define an abstract class?
Q14
In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
Q15
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()); } }
Q16
Which of these packages contains abstract keyword?
Q17
Which of these class relies upon its subclasses for complete implementation of its methods?
Q18
Which of these is not a correct statement?
Q19
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.
Q20
Which of these keywords cannot be used for a class which has been declared final?
Q21
Static members are not inherited to subclass.
Q22
Which of these class is superclass of every class in Java?
Q23
Which of this keyword must be used to inherit a class?
Q24
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(); } }
Q25
Which of these is not abstract?