wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java operators

Total questions: 8

Worksheet time: 4mins

Name
Class
Date
1.

Which of the following can be operands of arithmetic operators?

a)

Numeric

b)

Boolean

c)

Characters

d)

Boolean and characters

2.

Modulus operator, %, can be applied to which of these?

a)

Integers

b)

Floating "“ point numbers

c)

Both Integers and floating "“ point numbers.

d)

None of the above

3.

Decrement operator, “, decreases value of variable by what number?

a)

1

b)

2

c)

3

d)

4

4.

class increment {

public static void main(String args[])

{

double var1 = 1 + 5; 

double var2 = var1 / 4;

int var3 = 1 + 5;

int var4 = var3 / 4;

System.out.print(var2 + " " + var4);

 

}

a)

1 1

b)

1 0

c)

1.5 1

d)

1 0.2

5.

class increment {

public static void main(String args[]) 

{        

int g = 3;

System.out.print(++g * 8);

}

a)

25

b)

24

c)

32

d)

36

6.

class Output {

public static void main(String args[]) 

{    

int x , y;

x = 10;

x++;

--x;

y = x++;

System.out.println(x + " " + y);

}

a)

10 11

b)

11 10

c)

10 10

d)

11 11

7.

What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3

a)

Integers

b)

Floating "“ point numbers

c)

Boolean

d)

None of the above

8.

What is the value stored in x in following lines of code?

int x, y, z;

 x = 0;

 y = 1;

 x = y = z = 8;

a)

0

b)

9

c)

8

d)

7