Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

OOP-Quiz-5

Total questions: 20

Worksheet time: 14mins

Name
Class
Date
1.

A class member declared protected becomes a member of subclass of which type?

a)

public member

b)

private member

c)

protected member

d)

static member

2.

Inheritance means

a)

Sub class extends Base class

b)

Sub class extends super class

c)

Sub class create object of super class

d)

All of the above

3.

What type of inheritance does Java have?

a)

Single Inheritance

b)

Double Inheritance

c)

Multiple Inheritance

d)

Class Inheritance

4.

What is not type of inheritance?

a)

Single Inheritance

b)

Double Inheritance

c)

Multiple Inheritance

d)

Class Inheritance

5.

What are the features reused using Inheritance in Java?

a)

Variables

b)

Constants

c)

Methods

d)

All the above

6.

Which inheritance in java programming is not supported?

a)

Single inheritance

b)

Multilevel inheritance

c)

Multiple inheritance using classes

d)

Multiple inheritance using interfaces

7.

A ........... is a group of objects which have common properties.

a)

Class

b)

Sub Class

c)

Super Class

d)

None

8.

................. is the class from where a subclass inherits the features.

a)

Class

b)

Sub Class

c)

Super Class

d)

None

9.

Subclass is also called a ...........

a)

Derived Class

b)

Extended Class

c)

Child Class

d)

All the above

10.

Superclass is also called a ...............

a)

Base Class

b)

Parent Class

c)

Both A and B

d)

None

11.

is an example of

a)

Single Inheritance

b)

Multiple Inheritance

c)

Multilevel Inheritance

d)

None

12.

A class member declared protected becomes a member of subclass of which type?

a)

public

b)

private

c)

protected

d)

default

13.

Which of these is correct way of inheriting class A by class B?

a)

class B + class A {}

b)

class B inherits class A {}

c)

class B extends A {}

d)

class B extends class A {}

14.

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.

a)

1, 2 and 4

b)

Only 1 and 2

c)

1, 2 and 3

d)

2, 3 and 4

15.

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(); }}

a)

Base

b)

Derived

c)

Compile Time Error

d)

Run time error

16.

In a Multi-Level Inheritance in Java, the last subclass inherits methods and properties of ____.

a)

Only one immediate Superclass

b)

Few classes above it.

c)

All classes above it

d)

None of the mentioned

17.

Find Superclass and Subclass in the below Java code snippet?

class B

{

void show(){}

}

class A

{

void hide(){}

}

a)

B is superclass and A is subclass.

b)

A is superclass and B is a subclass.

c)

There is no superclass or subclass present.

d)

Both A and B are super classes

18.

What is the output of this program?

a)

0

b)

1

c)

2

d)

Compilation Error

19.

What is the output of this program?

a)

2 2

b)

3 3

c)

2 3

d)

3 2

20.

What is the output of this program?

a)

1 2

b)

2 1

c)

Runtime Error

d)

Compilation Error