Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

encapsulation

Total questions: 15

Worksheet time: 10mins

Name
Class
Date
1.

Which concept of Java is achieved by combining methods and attribute into a class?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Abstraction

2.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

3.

Which of the following is not OOPS concept in Java?

a)

Inheritance

b)

Encapsulation

c)

Polymorphism

d)

Compilation

4.

Evaluate the following Java expression, if x=3, y=5, and z=10:

++z + y - y + z + x++

a)

24

b)

23

c)

20

d)

25

5.

_____ is used to find and fix bugs in the Java programs.

a)

JVM

b)

JRE

c)

JDK

d)

JDB

6.

Which among the following best describes encapsulation?

a)

It is a way of combining various data members into a single unit

b)

It is a way of combining various member functions into a single unit

c)

It is a way of combining various data members and member functions into a single unit which can operate on any data

d)

It is a way of combining various data members and member functions that operate on those data members into a single unit

7.

Which among the following best defines abstraction?

a)

Hiding the implementation

b)

Showing the important data

c)

Hiding the important data

d)

Hiding the implementation and showing only the features

8.

Find which of the following uses encapsulation?

a)

void main(){

int a;

void fun() { int a=10;

System.out.println(a);

fun(); }

b)

class student{

int a;

public int b; };

c)

class student {

int a;

public void disp(){

System.out.println(a);

} }

d)

static topper() {

char name[10];

public int marks; }

9.

The type of resin we used in class.

a)

Polyester

b)

Polypropylene

c)

Polyurethane

d)

Polyethylene

10.

If two classes combine some private data members and provides public member functions to access and manipulate those data members. Where is abstraction used?

a)

Using private access specifier for data members

b)

Using class concept with both data members and member functions

c)

Using public member functions to access and manipulate the data members

d)

Data is not sufficient to decide what is being used

11.

Which of this keyword must be used to inherit a class?

a)

super

b)

this

c)

extent

d)

extends

12.

If class B is subclassed from class A then which is the correct syntax

a)

class B:A{}

b)

class B extends A{}

c)

class B extends class A{}

d)

class B implements A{}

13.

What is subclass in java?

a)

A subclass is a class that extends another class

b)

A subclass is a class declared inside a class

c)

Both above.

d)

None of the above.

14.

Which feature can be implemented using encapsulation?

a)

Inheritance

b)

Abstraction

c)

Polymorphism

d)

Overloading

15.

If data members are private, what can we do to access them from the class object?

a)

Create public member functions to access those data members

b)

Create private member functions to access those data members

c)

Create protected member functions to access those data members

d)

Private data members can never be accessed from outside the class