Loading
notes intro/old submit AP Problems the dump links
 

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:

  • I. a is true and b is true
  • II. a is true and c is true
  • III. atleast a, b, or c is true

Which is correct?

I I and II I and III I, II and III

 

 

4. EXTRA CREDIT: Which of the choices is equivalent to the following?
			  
			  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)

compile time error run time error the if condition is met the if condition is not met

 

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