1. 

public void foo( boolean a, boolean b)
{ 
    if( a ) 
    {
        System.out.println("A"); /* Line 5 */
    } 
    else if(a && b) /* Line 7 */
    { 
        System.out.println( "A && B"); 
    } 
    else /* Line 11 */
    { 
        if ( !b ) 
        {
            System.out.println( "notB") ;
        } 
        else 
        {
            System.out.println( "ELSE" ) ; 
        } 
    } 
}

A. If a is true and b is true then the output is "A && B"
B. If a is true and b is false then the output is "notB"
C. If a is false and b is true then the output is "ELSE"
D. If a is false and b is false then the output is "ELSE"

2. 

switch(x) 
{ 
    default:  
        System.out.println("Hello"); 
}
Which two are acceptable types for x?
  1. byte
  2. long
  3. char
  4. float
  5. Short
  6. Long

A. 1 and 3
B. 2 and 4
C. 3 and 5
D. 4 and 6

3. 

public class While 
{
    public void loop() 
    {
        int x= 0;
        while ( 1 ) /* Line 6 */
        {
            System.out.print("x plus one is " + (x + 1)); /* Line 8 */
        }
    }
}
Which statement is true?

A. There is a syntax error on line 1.
B. There are syntax errors on lines 1 and 6.
C. There are syntax errors on lines 1, 6, and 8.
D. There is a syntax error on line 6.

4. 

public void test(int x) 
{ 
    int odd = 1; 
    if(odd) /* Line 4 */
    {
        System.out.println("odd"); 
    } 
    else 
    {
        System.out.println("even"); 
    } 
}
Which statement is true?

A. Compilation fails.
B. "odd" will always be output.
C. "even" will always be output.
D. "odd" will be output for odd values of x, and "even" for even values.