wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz for Module2

Total questions: 10

Worksheet time: 17mins

Name
Class
Date
1.

Predict the output:

a)

1,3

b)

3,1

c)

1,1

d)

1,0

2.

Predict the output:

a)

20

b)

10

c)

Error in Object creation

d)

None of the above

3.

Predict the output:

a)

10

20

b)

10

c)

Compile Time Error

d)

20

4.

Predict the output:

a)

A

b)

B

c)

Compile Time Error

d)

No output

5.

Predict the output:

a)

A

b)

B

c)

Compile Time Error in line 10 : Cannot override.

d)

No output

6.

Predict the output:

a)

Option 1 : Both are Same

Option 2 : Both are Same

Option 3 : Both are Same

b)

Option 2 : Both are Same

Option 3 : Both are Same

c)

Option 2 : Both are Same

d)

Option 1 : Both are Same

7.

Predict the output:

a)

CompileTime Error @ Line 1

b)

allwelcome

c)

prints nothing

d)

hiallwelcome

8.

Which one of the below ways is correct to create a String from char

a)

char ch = 'a';

String str = new String(ch);

b)

char cha[] = {'a'};

String str = new String(cha);

c)

char ch='a';

String str = ch;

d)

char cha[] = {'a'};

String str = cha;

9.

Which of the following statements are true? Select all that apply.

A. We cannot override a static method in Java.

B. We can overload a static method in Java.

C. We cannot override a private method in Java.

a)

A and B

b)

B and C

c)

A, B and C

d)

None of the above

10.

Debug the given code:

char ch = 'c'; //line1

int num = 88; //line2

ch = num; //line3

System.out.println(ch); //line4

a)

X

b)

8

c)

Error at line3: Lossy conversion from int to char

d)

None of the above