6.What is the difference between >> and >>> operators?
-
A. >> is logical shift, >>> is arithmetic shift
-
B. >> preserves sign, >>> does not
-
C. Both are the same
-
D. >>> is not a valid operator in Java
>> preserves sign, >>> does not
>> preserves sign, >>> does not
7. Rewrite the following if-else statement using a ternary operator:
if (marks >= 40) {
result = "Pass";
} else {
result = "Fail";
}
-
A. result = marks >= 40 ? "Pass" : "Fail";
-
B. result = (marks > 40) ? "Fail" : "Pass";
-
C. result = "marks >= 40" ? Pass : Fail;
-
D. result = marks == 40 ? "Pass" : "Fail";
result = marks >= 40 ? "Pass" : "Fail";
result = marks >= 40 ? "Pass" : "Fail";
8.What is the output of the following program?
int a = 10, b = 20, c = 30;
System.out.println(a < b && b > c);
-
A. true
-
B. false
-
C. Compilation error
-
D. Runtime exception
false
false
9. What will be the output?
int a = 10;
a += a -= a * a;
System.out.println(a);
-
A. 10
-
B. 0
-
C. -90
-
D. Compilation error
-90
-90
10. What happens when you use the bitwise NOT (~) operator on 0?
-
A. 0
-
B. 1
-
C. -1
-
D. Compilation error
-1
-1