NEW
Font size
WorksheetsJava operators
Total questions: 8
Worksheet time: 4mins
Which of the following can be operands of arithmetic operators?
Numeric
Boolean
Characters
Boolean and characters
Modulus operator, %, can be applied to which of these?
Integers
Floating "“ point numbers
Both Integers and floating "“ point numbers.
None of the above
Decrement operator, “, decreases value of variable by what number?
1
2
3
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);
}
}
1 1
1 0
1.5 1
1 0.2
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
25
24
32
36
class Output {
public static void main(String args[])
{
int x , y;
x = 10;
x++;
--x;
y = x++;
System.out.println(x + " " + y);
}
}
10 11
11 10
10 10
11 11
What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3
Integers
Floating "“ point numbers
Boolean
None of the above
What is the value stored in x in following lines of code?
int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
0
9
8
7
