Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java variables

Total questions: 10

Worksheet time: 18mins

Name
Class
Date
1.
a)

0

b)

Garbage value

c)

Compilation error

d)

Runtime error

2.
a)

0

b)

Garbage value

c)

Compilation error

d)

Runtime error

3.
a)

The instance variables in b are given the same values as a

b)

The instance variables in a are given the same values as b

c)

a and b are considered to be the same object

d)

None of the mentioned options

4.

A single class can have

a)

only one instance

b)

two instances

c)

any number of instances

d)

None of the mentioned options

5.

Static means

a)

Class Level

b)

Object level

6.

Main method is static because to execute main method without creating object By JVM

a)

Yes

b)

No

7.

What is the ouput of the following code?

a)

x=10 x=10

b)

x=10 x=20

c)

x=30 x=30

d)

x=30 x=20

8.

Given that Student is a class, how many reference variables and objects are created by the following code?

a)

Three reference variables and two objects are created.

b)

Two reference variables and two objects are created.

c)

One reference variable and two objects are created.

d)

Three reference variables and three objects are created.

9.

Which of the following below live on the heap in java?

a)

class

b)

static

c)

method

d)

object

10.

Predict the output.

a)

Compilation Error

b)

20 40 10

c)

20 20 10

d)

20 10 10