wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java MCQ Test Day-2

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of these is not abstract?

a)

Thread

b)

List

c)

Array

d)

String

2.

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

3.

Which of these packages contains abstract keyword?

a)

java.lang

b)

java.io

c)

java.util

d)

java.System

4.

what is the output of the following code?

a)

2 2

b)

3 3

c)

Run Time Error

d)

Compile Time Error

5.

Which of these can be used to fully abstract a class from its implementation?

a)

Object

b)

Package

c)

Abstract Class

d)

Interfaces

6.

Which of the following access specifiers should be used with interfaces?

a)

public

b)

private

c)

protected

d)

default

7.

Which of the following is the correct way of implementing an interface salary by class manager?

a)

class manager extends salary {}

b)

class manager implements salary {}

c)

class manager imports salary {}

d)

class manager gets salary{}

8.

What is the output of the following code

a)

0

b)

2

c)

4

d)

compile time error

9.

what is the output of the following code

a)

0 1 2

b)

0 2 4

c)

0 0 4

d)

0 1 4

10.

What type of variable can be defined in an interface?

a)

public static

b)

public final

c)

private final

d)

static final

11.

Which among the following best describes polymorphism?

a)

It is the ability for a message/data to be processed in more than one form

b)

It is the ability for a message/data to be processed in only 1 form

c)

It is the ability for many messages/data to be processed in one way

d)

It is the ability for undefined message/data to be processed in at least one way

12.

If same message is passed to objects of several different classes and all of those can respond in a different way, what is this feature called?

a)

Inheritance

b)

Overloading

c)

Polymorphism

d)

Overriding

13.

Which among the following is not true for polymorphism?

a)

It is feature of OOP

b)

Ease in readability of program

c)

Helps in redefining the same functionality

d)

Increases overhead of function definition always

14.

In Java, which concept allows us to implement runtime polymorphism?

a)

Method Overloading

b)

Method Overriding

c)

Constructors

d)

static methods

15.

What is the output of the following code?

a)

Some sound

b)

Bark

c)

Some Sound

Bark

d)

compile time error

16.

Which of these keywords must be used to monitor for exceptions?

a)

try

b)

catch

c)

throw

d)

finally

17.

Which of these keywords is used to manually throw an exception?

a)

try

b)

catch

c)

throw

d)

finally

18.

What is the output of the following code?

a)

Hello

b)

World

c)

Hello World

d)

HelloWorld

19.

Which of these is a super class of all exceptional type classes?

a)

Throwable

b)

Exception

c)

Error

d)

Catchable

20.

What is the output of the following code?

a)

A

b)

B

c)

Hello

d)

Runtime Exception