gs gs128 Java Inheritance - Java Inheritance - Quiz No.1
gs gs128 Java Quiz
This quiz belongs to book/course code gs gs128 Java of gs organization. We have 136 quizzes available related to the book/course Java. This quiz has a total of 17 multiple choice questions (MCQs) to prepare and belongs to topic Java Inheritance. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Which of this keyword must be used to inherit a class?
super
this
extent
extends
Question 2: A class member declared protected becomes a member of subclass of which type?
public member
private member
protected member
static member
Question 3: Which of these is correct way of inheriting class A by class B?
class B + class A {}
class B inherits class A {}
class B extends A {}
class B extends class A {}
Question 7: 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) } }
1 2
2 1
Runtime Error
Compilation Error
Question 8: What is not type of inheritance?
Single inheritance
Double inheritance
Hierarchical inheritance
Multiple inheritance
Question 9: Using which of the following, multiple inheritance in Java can be implemented?
Interfaces
Multithreading
Protected methods
Private methods
Question 10: All classes in Java are inherited from which class?
java.lang.class
java.class.inherited
java.class.object
java.lang.Object
Question 11: In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
Protected
Private
Public
Static
Question 14: Which of the following is used for implementing inheritance through an interface?
inherited
using
extends
implements
Question 15: Which of the following is used for implementing inheritance through class?
inherited
using
extends
implements
Question 16: 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.
Runtime error
Compile time error
Code runs successfully
First called method is executed successfully