wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Program_3

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

1. What is the purpose of the raiseSalary() method in the Employee class?

a)

a) To set a new salary directly

b)

b) To increase the salary by a given percentage

c)

c) To print the salary details

d)

d) To decrease the salary

2.

What is the access modifier for the instance variables id, name, and salary?

a)

a) public

b)

b) private

c)

c) protected

d)

d) default

3.

Which keyword is used to create an object of the Employee class?

a)

a) this

b)

b) new

c)

c) super

d)

d) create

4.

Which concept of OOP is shown by using private variables and public getter methods?

a)

a) Inheritance

b)

b) Encapsulation

c)

c) Polymorphism

d)

d) Abstraction

5.

What does the this keyword refer to inside the constructor?

a)

a) The parent class

b)

b) The current object of the class

c)

c) The static variable

d)

d) The superclass

6.

Which method automatically executes when an object is printed?

a)

a) print()

b)

b) display()

c)

c) toString()

d)

d) show()

7.

Which part of the program demonstrates data hiding?

a)

a) Private variables with public getters

b)

b) Printing salary

c)

c) Using toString()

d)

d) Using new keyword

8.

Which of the following best defines method overriding as used here?

a)

a) Defining two methods with same name in one class

b)

b) Redefining a method from superclass in subclass

c)

c) Calling a static method from another class

d)

d) Changing method parameters

9.

When is the constructor called in the program?

a)

a) When an object is declared

b)

b) When an object is created using new

c)

c) When a method is called

d)

d) When the program ends

10.

Which keyword is used inside the constructor to refer to instance variables?

a)

a) this

b)

b) super

c)

c) static

d)

d) final