wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

interfaces, final , inheritance

Total questions: 20

Worksheet time: 19mins

Name
Class
Date
1.

Which of the following statement(s) is/are not true?

a)

Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data encapsulation.

b)

Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword.

c)

The term "class variable" is another name for non-static field.

d)

A local variable stores temporary state; it is declared inside a method

2.
a)

5

b)

4

c)

3

d)

error

3.

Which of the following is/are TRUE about print() and println() methods?

a)

print() prints in a single line only and multiple lines cannot be printed in any way.

b)

print() prints and then appends a line break.

c)

println()prints and then appends a line break.

d)

println() prints in a single line only and multiple lines cannot be printed.

4.

Which of the following is a valid declaration of an object of class Fun

a)

Fun obj=new Fun;

b)

obj=new Fun();

c)

Fun obj=new Fun();

d)

new Fun obj;

5.
a)

10

0

5

b)

12

0

5

c)

10

5

0

d)

12

0

5

6.

An expression involving byte, int, and literal numbers is promoted to which of these?

a)

int

b)

long

c)

byte

d)

float

7.
a)

25

b)

24

c)

32

d)

33

8.

a)

0 2 4 6 8

b)

1 2 3 4 5

c)

0 1 2 3 4 5 6 7 8 9

d)

1 2 3 4 5 6 7 8 9 10

9.

Which of the following statements are incorrect?

a)

public members of class can be accessed by any code in the program.

b)

private members of class can be inherited by a sub class, and become protected members in sub class.

c)

private members of class can only be accessed by other members of the class.

d)

protected members of a class can be inherited by a sub class, and become private members of the sub class.

10.
a)

0

b)

1

c)

2

d)

compilation error

11.

super keyword in Java is used for ?

a)

to refer to immediate child class of a class.

b)

to refer to current class object.

c)

to refer to immediate parent class of a class.

d)

to refer to static member of parent class.

12.

Which is true ?

a)

"X extends Y" is correct if X and Y are either both classes or both interface.

b)

"X extends Y" is correct if and only if X is a interface and Y is a class.

c)

"X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.

d)

"X extends Y" is correct if and only if X is a class and Y is an interface.

13.
a)

only A and B will be printed.

b)

only B will be printed.

c)

A, B, C will be printed.

d)

only C will be printed.

14.

If a class inheriting an abstract class does not define all of its function then it will be known as?

a)

abstract

b)

A simple class

c)

Static class

d)

None of the mentioned

15.

Which of these is not a correct statement?

a)

Every class containing abstract method must be declared abstract.

b)

Abstract class defines only the structure of the class not its implementation.

c)

Abstract class can be initiated by new operator.

d)

Abstract class can be inherited.

16.
a)

0

b)

2

c)

run time error

d)

compile time error

17.

Which of the statement is false about an abstract class ?

a)

An abstract class is a class that contains one or more abstract methods.

b)

An abstract class cannot have normal method.

c)

An abstract class cannot be instantiated.

d)

An abstract class can be extended.

18.

Which of the following statement is true about an Interface ?

a)

Interface can not be nested inside another interface.

b)

Interface cannot implement a class.

c)

Interface can not extend one or more other interface.

d)

Methods inside Interface can be static, final, native or strictfp.

19.
a)

1,3 and 4

b)

1,2 and 4

c)

2,3 and 4

d)

1,2,3 and 4

20.

a)

1 and 2 only

b)

2,3 and 5

c)

3,4 and 5

d)

2 and 4