Test Series - java

Test Number 29/64

Q: What is the output of the Java code snippet below?
int a = 20, b=30;
boolean result = a&b?true:false;
System.out.println(result);
A. false
B. true
C. 0
D. Compiler error
Solution: no solution
Q: What is the output of the Java code snippet below?
int a = 4, b=7;
int result = (true?a&b:a|b)>3?120:150;
System.out.println(result);
A. 4
B. 120
C. 150
D. Compiler error
Solution: no solution
Q: What is the output of Java code snippet below?
final int a = 25, b=33;
String name = !true?"Dino":"Tom";
System.out.println(name);
A. Empty
B. Dino
C. Tom
D. Compiler error
Solution: no solution
Q: What is the output of Java code snippet below?
int a = 25, b=33;
String name = true?"CAT":;
System.out.println(name);
A. Empty
B. CAT
C.  null
D. Compiler error
Solution: You can not skip any of the two expressions of a Ternary or Conditional operator (?:).

You Have Score    /4