Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JAVA FUNDAMENTALS

Total questions: 12

Worksheet time: 4mins

Name
Class
Date
1.

Which of the following can be operands of arithmetic operators?

a)

Numeric

b)

Boolean

c)

Both Numeric & Characters

d)

Characters

2.

What will be the output of the following Java program?

class Output {

public static void main(String args[]) {

int a = 1;

int b = 2;

int c;

int d;

c = ++b;

d = a++;

c++;

b++;

++a;

System.out.println(a + " " + b + " " + c); }

}

a)

3 2 4

b)

3 2 3

c)

2 3 4

d)

2 4 4

e)

3 4 4

3.

Which of these can be returned by the operator &?

a)

Integer

b)

Boolean

c)

Integer or Boolean

d)

Character

4.

What will be the output of the following Java program?

class comma_operator {

public static void main(String args[]) {

int sum = 0;

for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)

sum += i;

System.out.println(sum); }

}

a)

5

b)

4

c)

6

d)

14

5.

Which of these can not be used for a variable name in Java?

a)

identifier

b)

identifier & keyword

c)

keyword

d)

none of the mentioned

6.

What will be the output of the following Java code?

class operators {

public static void main(String args[]) {

int x = 8;

System.out.println(++x * 3 + " " + x); }

}

a)

24 8

b)

24 9

c)

27 9

d)

27 8

7.

Which of the following is not an operator in Java?

a)

instanceof

b)

sizeof

c)

>>>=

d)

new

8.

What will be the output of the following Java program?

class jump_statments {

public static void main(String args[]) {

int x = 2;

int y = 0;

for ( ; y < 10; ++y) {

if (y % x == 0)

continue;

else if (y == 8)

break;

else

System.out.print(y + " "); }

}

}

a)

1 3 5 7

b)

2 4 6 8

c)

1 3 5 7 9

d)

1 2 3 4 5 6 7 8 9

9.

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a)

while

b)

do-while

c)

for

d)

none of the mentioned

10.

What will be the output of the following Java code?

class Relational_operator {

public static void main(String args[]) {

int var1 = 5;

int var2 = 6;

System.out.print(var1 > var2); }

}

a)

5

b)

6

c)

true

d)

false

11.

Which of these is not a bitwise operator?

a)

&

b)

&=

c)

|=

d)

<=

12.

What is the output of relational operators?

a)

Integer

b)

Boolean

c)

Characters

d)

Double