Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JAVA QUIZ

Total questions: 11

Worksheet time: 6mins

Name
Class
Date
1.

Will this code compile?

a)

Yes

b)

No

2.

Will this code compile without error?

a)

Yes

b)

No

3.

Will this code compile?

a)

Yes

b)

No

4.

What will happen when you run and compile the following code?

a)

1

b)

0

c)

compilation error

d)

runtime error

5.

What will happen when you run and compile the following code?

a)

Hello

b)

Compilation error

c)

Runtime error

d)

None of the above

6.

What will happen when you run and compile the following code?

a)

Hi

b)

Compilation error

c)

No output

d)

Runtime error

7.

Which class has defined the equals(object o) method?

a)

String

b)

Object

c)

Main

d)

System

8.

What will happen when you compile and run the following code?

a)

Int version

b)

Long version

c)

Compilation error

d)

Runtime error

9.

Which statement is true for the following code?

a)

The code will compile without changes.

b)

The code will compile if public tree{} {Plant{}:} is added to the tree class

c)

The code will compile if public tree{} {tree{}:} is added to the Plant class

d)

The code will compile if public plant{} {this {"fern"}:} is added to the Plant class

10.

what will be the result of the following code?

a)

Int long

b)

Short long

c)

Compilation fails

d)

An exception is thrown at the runtime

11.

Which three methods, inserted individual at line 14, will correctly complete class 2

a)

Int foo{}{/*more code here*/.}

b)

Void foo{}{/*more code here*/.}

c)

Public void foo{}{/*more code here*/.}

d)

Private void foo{}{/*more code here*/.}

e)

Protected void foo{}{/*more code here*/.}