Mcq On Java operators And Assignments

31. What should be expression1 evaluate to in using ternary operator as in this line?

expression1 ? expression2 : expression3

A. Integer
B. Floating – point numbers
C. Boolean
D. None of the mentioned

View Answer


32. 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. 1
C. 9
D. 8

View Answer


33. What is the order of precedence (highest to lowest) of following operators?

1. &
2. ^
3. ?:

A. 1 -> 2 -> 3
B. 2 -> 1 -> 3
C. 3 -> 2 -> 1
D. 2 -> 3 -> 1

View Answer


34. What is the output of this program?

class operators
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
int var3;
var3 = ++ var2 * var1 / var2 + var2;
System.out.print(var3);
}
}

A. 10
B. 11
C. 12
D. 56

View Answer


35.What is the output of this program?

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 8
D. 27 9

View Answer







Also check :


Discussion


* You must be logged in to add comment.