NEW
Font size
S
M
L
XL
Worksheetsoperators(part-2_26/07)
Total questions: 10
Worksheet time: 8mins
Name
Class
Date
1.
The first part of a conditional operator is __________.
a)
True statement
b)
False statement
c)
Boolean Condition
d)
int main (void)
2.
What is the format for conditional operators?
a)
;
b)
? ; :
c)
? :
d)
: ? ;
3.
The second part of a conditional operator is __________.
a)
True statement
b)
False statement
c)
Boolean Condition
d)
int main (void)
4.
The third part of a conditional operator is __________.
a)
True statement
b)
False statement
c)
Boolean Condition
d)
int main (void)
5.
The first part of a conditional operator is __________.
a)
True statement
b)
False statement
c)
Boolean Condition
d)
int main (void)
6.
Java Ternary operator is sometimes called
a)
relational operator
b)
Condition Operator
c)
logical operator
d)
None of these
7.
What is the output of the code snippet with the ternary operator?
int p=5;
System.out.print("Hello ");
(p<6)?5:6;
a)
Hello 5
b)
Hello 6
c)
Hello
d)
compile error due to wrong syntax
8.
String name = "java";
int marks = name == "java"?10:20;
System.out.println("Marks=" + marks);
a)
marks=0
b)
marks=10
c)
marks=20
d)
Compiler error
9.
String name = "cat";
int marks = name == "Cat"?10:20;
System.out.println("Marks=" + marks);
a)
Marks=0
b)
Marks=10
c)
Marks=20
d)
compile error
10.
int a = 20, b=30;
int total = a>10&&b<10?65:75;
System.out.println(total);
a)
0
b)
65
c)
75
d)
error
Reset
