Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Operator and expressions in Java

Total questions: 34

Worksheet time: 34mins

Name
Class
Date
1.

Evaluate the following expression, if the values of the variables are a = 2, b = 3 and c = 9.

a * (++b) % c

(a)  

2.

If int m = 5 and int n = 2 output the value of m after execution in the following expression:

n = m + m % n;

(a)  

3.

++ increases the value of a variable by 1

a)

assignment operator

b)

decrement operator

c)

increment operator

d)

sentinel

4.

Which statement(s) are equivalent to i = i + 1?

a)

i += 1

b)

i++

c)

i -= 1

d)

i--

5.

what is modulo operation used for ?

a)

performs division

b)

performs division and gives no remainder

c)

performs division and gives remainder

d)

does not perform division

6.

arithmetic operators return a value. True or false?

a)

true

b)

false

7.

Find the output of the following snippet.


class Numbers

{

public static void main(String args[])

{

int a=20, b=10;

if((a<b)&&(b++ <25))

{

System.out.println("this is any language logic");

}

System.out.println(b);

}

}

a)

10

b)

12

c)

11

d)

Compilation Error

8.

Please write correct output in following space-

a)

10

b)

20

c)

No Output

d)

Error

9.

Choose the logical operators

a)

And

b)

Less than

c)

OR

d)

Not Equal

10.

What is the result of 13<=13 ?

a)

True

b)

False

c)

Both true and false

d)

None

11.

The result of AND operator is always true, if both the conditions results are _____

a)

True

b)

False

12.

What is the value in variable A?

A+=112

a)

112

b)

111

c)

113

d)

130

13.

in Java every statement is end with _____?

a)

Comma

b)

Colon

c)

Semicolon

d)

Brace

14.

Java is case sensitive language.

a)

True

b)

False

15.

Write the java expression for the following

ax5+bx3+c

(a)  

16.

What will be the value of m if m = 8

m *= 8

(a)  

17.

Write the output of the following


( 4 > 7 ) || ( 7 < 15 )

a)

true

b)

false

18.

The operator '==' checks for

a)

Equal values

b)

Greater values

c)

lesser values

19.

String values are always written in

a)

Single quotes

b)

without quotes

c)

Double quotes

20.

true && true

a)

true

b)

false

21.

false == false

a)

true

b)

false

22.

true != true

a)

true

b)

false

23.

false || true

a)

true

b)

false

24.

false && false

a)

true

b)

false

25.

true || true

a)

true

b)

false

26.

true == false

a)

true

b)

false

27.

false != true

a)

true

b)

false

28.

Types of Java Operators

a)

logical

b)

arithmetic

c)

relational

d)

all of above

29.

Java expression

a<b

Types of operator for above expression is

a)

Relational

b)

logical

c)

arithmetic

30.

Evaluate this expression

a=3,b=4

!(a==0) && (b<5)

a)

true

b)

false

31.

Which of the following statement is valid

a)

int a+b=5;

b)

double char =m;

c)

int name;

name = 5;

d)

IQ = 5;

int IQ;

32.

Java expression

a&&b

Type of operator

a)

relational

b)

logical

c)

arithmetic

33.

Which one is correct?

a)

public static main(Strings[] args) { }

b)

public private static main(Strings[] args) { }

c)

public static void main(Strings[] args) { }

d)

public void static main(Strings[] args) { }

34.

(=) sign means

a)

equals and it is used for math problems in Java

b)

assignment operator. It used to assign a value