wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Programming Quiz - 3

Total questions: 30

Worksheet time: 17mins

Name
Class
Date
1.

Which of these cannot be used for a variable name in Java?

a)

identifier & keyword

b)

identifier

c)

keyword

d)

none of the mentioned

2.

Which component is used to compile, debug and execute the java programs?

a)

JRE

b)

JIT

c)

JDK

d)

JVM

3.

Which of the following is not an OOPS concept in Java?

a)

Polymorphism

b)

Compilation

c)

Inheritance

d)

Encapsulation

4.

Which of these are selection statements in Java?

a)

break

b)

continue

c)

for()

d)

if()

5.

What is the value stored in x in following lines of code?

int x, y, z;

 x = 0;

 y = 1;

 x = y = z = 8;

a)

1

b)

9

c)

8

d)

0

6.

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

7.

Which of the following for loop declaration is not valid?

a)

for ( int i = 99; i >= 0; i / 9 )

b)

for ( int i = 7; i <= 77; i += 7 )

c)

for ( int i = 20; i >= 2; - -i )

d)

for ( int i = 2; i <= 20; i = 2* i )

8.

What does JVM stands for?

a)

Java Variable Machine

b)

Java Virtual Machine

c)

Java Virtual Mechanism

d)

None of the above

9.

What are the main Distribution types of Java Software?

a)

Java SE (Java Standard Edition)

b)

Java EE (Java Enterprise Edition)

c)

Java ME (Java Micro Edition)

d)

All the above

10.

What is JVM ?

a)

JVM is the confined memory area

b)

All java programs run inside JVM memory

c)

JVM provides security to the computer by giving controlled access to Files and Memory on a computer

d)

All the above

11.

Output of following Java Program?

a)

Derived::show() called

b)

Base::show() called

c)

Run time Error

d)

Compilation Error

12.

What will be the output of following program?

a)

Base::show() called

b)

Derived::show() called

c)

Compiler Error

d)

Runtime Error

13.

Which inheritance in java programming is not supported

a)

Multiple inheritance using classes

b)

Multiple inheritance using interfaces

c)

Multilevel inheritance

d)

Single inheritance

14.

Predict the output of following program

a)

Base

b)

Derived

c)

Compiler Error

d)

Runtime Error

15.

A class member declared protected becomes a member of subclass of which type?

a)

public member

b)

private member

c)

protected member

d)

static member

16.

In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?

a)

Protected

b)

Private

c)

Public

d)

Static

17.

If super class and subclass have same variable name, which keyword should be used to use super class?

a)

super

b)

this

c)

upper

d)

classname

18.

Order of execution of constructors in Java Inheritance is

a)

Base to derived class

b)

Derived to base class

c)

Random order

d)

none

19.

In a Multi-Level Inheritance in Java, the last subclass inherits methods and properties of ____.

a)

Only one immediate Superclass

b)

Few classes above it.

c)

All classes above it

d)

None of the mentioned

20.

Class Cat extends Animal. Which is NOT a valid declaration?

a)

Cat x = new Cat();

b)

Animal X = new Animal();

c)

Cat x = new Animal();

d)

Animal x = new Cat();

21.
What does polymorphism mean?
a)
Changing shapes
b)
Having many forms
c)
Being unchangeable
d)
Easy
22.

When overloading a method, the method header ________ .

a)

Must exactly match the header of the method you are overloading.

b)

Must have the same name, but differ in order, number, or type of parameters.

c)

Can differ in name, but must have the same number and order of parameters.

d)

Can be completely different from the method you are overloading, but must have @Override.

23.
A(n) ____________________ method cannot be overridden by a subclass.
a)
final
b)
private
c)
public
d)
static
24.
When the subclass method is intended as a replacement of the superclass method.
a)
Overriding
b)
Dependency
c)
Extension
d)
Aggregation
25.

What is the output of this program?

a)

0

b)

1

c)

2

d)

Compilation Error

26.

What is the output of this program?

a)

2 2

b)

3 3

c)

2 3

d)

3 2

27.

What is the output of this program?

a)

1 2

b)

2 1

c)

Runtime Error

d)

Compilation Error

28.
Inheritance is used when the relationship between two classes is a(n) _______ relationship.
a)
"HAS-A"
b)
"PART-OF-A"
c)
"IS-A"
d)
inverse
29.

Which of the following is/are false about inheritance in Java?

I. A subclass inherits all the methods and variables of the superclass.

II. A subclass can override the methods of its superclass

III. A subclass has access to the private instance variables of the superclass.

a)

I only

b)

II only

c)

III only

d)

I and II only

e)

I and III only

30.

super keyword is used to access

a)

only subclass methods

b)

parent class variables and methods

c)

subclass variables and methods

d)

only parent class methods