Quiz 9a - Boolean expressions
id:
1.You should be extra careful because of rounding when comparing which type of data:
int objects char doubles
2. True or false: In the conditional statement:
If (a || b)
if a is true, it will not check to see if b is true.
true false
3. Examine the following code fragment:
if (a && (b || c))
This condition will be met if:
Which is correct?
I I and II I and III I, II and III
if (a==0 && b==0)
if (a==0 || b==0) if (!(a!=0 || b!=0)) if (!(a==0 || b==0)) if (!(a!=0 && b!=0))
5. If a=0, what will happen
if (a!=0 && b/a==2)
compile time error run time error the if condition is met the if condition is not met
6. If a=0, what will happen
if (b/a==2 && a!=0)
7. What is returned by the following statement:
String name1="jeff"; String name2="eric"; if (name1.compareTo(name2)>0) System.out.print("name1 is greater"); else System.out.print("name2 is greater");
compile time error run time error name1 is greater name2 is greater