wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaLab-534

Total questions: 10

Worksheet time: 4mins

Name
Class
Date
1.

'static' & 'this' always go together

a)

True

b)

False

2.

Function with Var-Args and 'For-each' loop usually go together.

a)

True

b)

False

3.

What will be the output :

int a=12;

Sop(a>>2);

a)

Compile Error

b)

6

c)

3

d)

24

4.

Any 'for' loop can be replaced with 'Enhanced For' loop.

a)

True

b)

False

5.

When is the Garbage collector invoked? (You can select multiple answers if required)

a)

As soon as an object is de-referenced.

b)

JVM will schedule the activity for Garbage collector (Automatic)

c)

Programmer can invoke whenever required

d)

There is no Garbage Collector in Java

6.

Analyse the program and select the best answer(s). Click on the image to zoom. Can select multiple answers if required.

a)

No error

b)

Creates a new object

c)

Compile error

d)

Run-time exception

7.

class Test{

public static void main(String[] args) {

new Test();

---- }

What does 'new Test()' do in the above program?

a)

Gives compiler error

b)

Creates an object

c)

Generates run-time exception

d)

Does nothing.

8.

class Test{

public static void main(String[] args) {

new Test();

---- }

Objects created like above are called?

a)

Unknown objects

b)

Anonymous objects

c)

Zero-argument objects

d)
9.

What will be the output of:

int a=1, b=9;

Sop("a+b=",a+b);

a)

10

b)

a+b=10

c)

a+b=19

d)

Error

10.

What is your opinion about the code:

int a[ ] = { 1, 2, 3};

int[ ] b = { 1, 2, 3, 4, 5};

a=b;

a)

Compiler error

b)

'b' cannot be assigned to 'a' : Runtime exception

c)

No error

d)