WorksheetsOOP-Quiz-5
Total questions: 20
Worksheet time: 14mins
A class member declared protected becomes a member of subclass of which type?
public member
private member
protected member
static member
Inheritance means
Sub class extends Base class
Sub class extends super class
Sub class create object of super class
All of the above
What type of inheritance does Java have?
Single Inheritance
Double Inheritance
Multiple Inheritance
Class Inheritance
What is not type of inheritance?
Single Inheritance
Double Inheritance
Multiple Inheritance
Class Inheritance
What are the features reused using Inheritance in Java?
Variables
Constants
Methods
All the above
Which inheritance in java programming is not supported?
Single inheritance
Multilevel inheritance
Multiple inheritance using classes
Multiple inheritance using interfaces
A ........... is a group of objects which have common properties.
Class
Sub Class
Super Class
None
................. is the class from where a subclass inherits the features.
Class
Sub Class
Super Class
None
Subclass is also called a ...........
Derived Class
Extended Class
Child Class
All the above
Superclass is also called a ...............
Base Class
Parent Class
Both A and B
None
is an example of
Single Inheritance
Multiple Inheritance
Multilevel Inheritance
None
A class member declared protected becomes a member of subclass of which type?
public
private
protected
default
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 {}
Which of the following is true about inheritance in Java?
1) Private methods are final.
2) Protected members are accessible within a package and
inherited classes outside the package.
3) Protected methods are final.
4) We cannot override private methods.
1, 2 and 4
Only 1 and 2
1, 2 and 3
2, 3 and 4
Predict the output of following program. Note that fun() is public in base and private in derived.
class Base { public void foo() { System.out.println("Base"); }} class Derived extends Base { private void foo() { System.out.println("Derived"); } } public class Main { public static void main(String args[]) { Base b = new Derived(); b.foo(); }}
Base
Derived
Compile Time Error
Run time error
In a Multi-Level Inheritance in Java, the last subclass inherits methods and properties of ____.
Only one immediate Superclass
Few classes above it.
All classes above it
None of the mentioned
Find Superclass and Subclass in the below Java code snippet?
class B
{
void show(){}
}
class A
{
void hide(){}
}
B is superclass and A is subclass.
A is superclass and B is a subclass.
There is no superclass or subclass present.
Both A and B are super classes
What is the output of this program?
0
1
2
Compilation Error
What is the output of this program?
2 2
3 3
2 3
3 2
What is the output of this program?
1 2
2 1
Runtime Error
Compilation Error
