wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

OOP_1

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What will str1==str2 return if both refer to the same string literal?

a)

true

b)

false

c)

compilation error

d)

0

2.

What is the purpose of a constructor?

a)

To destroy objects

b)

to call methods

c)

to initialise object

d)

to inherit classes

3.

Which of these is an incorrect array declaration?

a)

int arr[] = new int[5]

b)

int [] arr = new int[5]

c)

int arr[] = new int[5]

d)

int arr[] = int [5] new

4.

Which access modifier makes a member accessible within the same package?

a)

public

b)

private

c)

protected

d)

default(no modifier)

5.

What does the static keyword mean in a method declaration?

a)

The method belongs to an object

b)

The method can only be called once

c)

The method belongs to the class, not instances

d)

The method cannot be accessed

6.

What is constructor overloading?

a)

Having multiple constructors with different names

b)

Having multiple constructors with different return types

c)

Having multiple constructors with different parameters

d)

Having a constructor inside a method

7.

Which of these method of String class can be used to test to strings for equality?

a)

isequal()

b)

isequals()

c)

equal()

d)

equals()

8.

What will be the output of the following Java program?

a)

9

b)

10

c)

11

d)

12

9.
a)

false false

b)

true true

c)

true false

d)

false true

10.

How many constructors can a class have in Java?

a)

only one

b)

two

c)

As many as needed (overloaded)

d)

none