Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

WCF Training Test II

Total questions: 20

Worksheet time: 23mins

Name
Class
Date
1.

Choose the correct statement about the given code:

a)

The code will not compile because of line 2.

b)

The code will not compile because of line 4.

c)

The code will not compile because of line 7.

d)

It compiles but throws an exception at runtime.

2.

Choose the correct statement about the given code:

a)

The code will not compile because of line 3.

b)

The code will not compile because of line 4.

c)

The code will not compile because of lines 3 and 4.

d)

It compiles and runs without issue.

3.

Choose the correct statement about the given code:

a)

It compiles without issue.

b)

The code will not compile because of line 2.

c)

The code will not compile because of line 4.

d)

The code will not compile because of lines 2 and 5.

4.

Which statements are true about the given code? (Choose all that apply)

a)

The CanBark interface doesn’t compile.

b)

A class that implements CanBark inherits both the makeSound() and bark() methods.

c)

A class that implements CanBark only inherits the bark() method.

d)

An interface cannot extend another interface.

5.

What is the output of the given code?

a)

Lizard laying eggs

b)

The code will not compile because of line 4.

c)

The code will not compile because of line 2.

d)

The code will not compile because of line 9.

6.

What is the result of the given code?

a)

Bird is flying

b)

Pelican is flying

c)

The code will not compile because of line 4.

d)

The code will not compile because of line 9.

7.

Given that a class exists in both the and packages, what is the result of compiling the following class?

a)

The code does not compile because of lines 1 and 2.

b)

The code does not compile because of line 4.

c)

The code does not compile because of line 5.

d)

The code compiles without issue.

8.

What is the result of compiling and executing the following class?

a)

It does not compile.

b)

It compiles but throws an exception at runtime.

c)

It compiles and outputs 5.

d)

It compiles and outputs 15.

9.

Given the code, what values inserted in order into the blank lines, allow the code to compile?

a)

import, class, null

b)

import, interface, void

c)

package, int, int

d)

package, class, long

10.

Which statement about the given code is correct?

a)

The code does not compile due to line g1.

b)

The code does not compile due to line g2.

c)

The code does not compile due to line g3.

d)

The code compiles and runs without issue.

11.

Which of these class is highest in hierarchy in java

a)

java.lang.Exception

b)

java.lang.Error

c)

java.lang.Throwable

d)

java.lang.Object

12.

Choose the CORRECT exception


String department="JTMK";

Integer no=Integer.parseInt(department);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundsException

13.

What is the output of the following?

12: String b = "12";

13: b += "3";

14: b.reverse();

15: System.out.println(b.toString());

a)

12

b)

123

c)

321

d)

The code does not compile.

14.

What is the output of the following?


String teams = new String("694");

teams.concat(" 1155");

teams.concat(" 2265");

teams.concat(" 2869");

System.out.println(teams);

a)

694

b)

694 1155 2265 2869

c)

The code compiles but outputs something else.

d)

The code does not compile.

15.

What is the output of the following?

a)

false 1

b)

false 2

c)

true 1

d)

true 2

16.

Choose correct option.

a)

Base::show() called

b)

Derived::show() called

c)

Compiler Error

d)

Runtime Error

17.

Which of the following are checked exceptions? (Choose all that apply.)


class One extends RuntimeException{}

class Two extends Exception{}

class Three extends Error{}

class Four extends One{}

class Five extends Two{}

class Six extends Three{}

a)

One

b)

Two

c)

Three

d)

Four

e)

Five

18.

Which represent the order in which the following statements can be assembled into a program

that will compile successfully? (Choose all that apply)

A: class Rabbit {}

B: import java.util.*;

C: package animals;

a)

A, B, C

b)

B, C, A

c)

C, B, A

d)

B, A

e)

C, A

19.

Which of the following lines of code compile? (Choose all that apply)

a)

int i1 = 1_234;

b)

double d1 = 1_234_.0;

c)

double d2 = 1_234._0;

d)

double d3 = 1_234.0_;

e)

double d4 = 1_234.0;

20.

Which of these operators is used to allocate memory for an object?

a)

malloc

b)

alloc

c)

new

d)

this