HOME | Overview | Syllabus | Instructor | Lectures | Laboratories | Readings | Assignments | Resources | Other Links
CS 1713 Lecture 19: Review
October 13, 1999

Types of problems that you can expect on the exam:

Review Chapters 1 to 5: MULTIPLE CHOICE


1.  Which of the following evaluate to 0?
      a.     3 % 2 - 2
      b.     1 - 4 % 3
      c.     6 % 3 - 1
      d.     6 / 2 + 1
      e.     2 + 6 % 1

2.      The value of the following expression is
          55 % 7 + 19/3 + 1
     a.     14
     b.     14.3...
     c.     13
     d.     13.3...
     e.      undefined

3.      What is printed if the following segment of code is executed?
         A = 35;
     B = 7;
     if ( A % B == 0 )
        { A = A - 10;}
     else
        { A = A + 10; }
     System.out.println( A);

         a.     35
         b.     25
         c.     7
         d.     45
         e.     invalid code

4.     Given the statement                if (x >= 25 && x < 75)
        which value of x would make this statement true?
        a.     100
        b.     75
        c.     20
        d.     60
        e.     90

5.     What is the value of the following expression if a, b, and d are
        true and c is false?
                                           a  ||  !b && c  || d
        a.     true
        b.     false
        c.     error

6.     If switch is a boolean variable, the expression   if ( switch == true )
        can be better written as

        a.     if (switch)
        b.     if (switch = true)
        c.     if (! switch )
        d.     if (!switch == false )

7.     In order for the expression         if ( (a + b) > c || (a + d) > c )
        to evaluate as true, which of the following must be true?

        a.     Both (a + b) > c and (a + d) > c must evaluate as true.
        b.     Neither (a + b) > c nor (a + d) > c may evaluate as true.
        c.     Either (a + b) > c or (a + d) > c must evaluate as true, but both may not be true.
        d.     Either (a + b) > c or (a + d) > c must evaluate as true or both may be true.

8.     The statement      if (5 < y <= 12) { System.out.println(y);}
        is incorrect.  It can be correctly written as:

        a.     if 5 < y <= 12 {System.out.println(y);}
    b.  if (5 < y || y <= 12) { System.out.println(y);}
    c.  if (5 < y && y <= 12) { System.out.println(y);}
    d.  if (y > 5) { System.out.println(y); }
    e.  if (y <= 12) { System.out.println(y); }

9.     What is the value of A after the following program segment is executed?

    A = 750;
    if ( A > 0 )
    {
        if ( A >= 1000)
          { A = 0; }
        else if ( A < 500 )
          { A = A * 2; }
        else
          { A = A * 10;}
    }
    else
    {
        A = sqrt(12);
    }

        a.      0
        b.     1500
        c.     750
        d.     7500
        e.     144

10.  What is the value of A after the following program segment is executed?

    A = 1250;
    if (A < 0 )
        { A = A * 2; }
    else if (A < 500 )
        { A = 0; }
    else if ( A <= 1000 )
        { A = A * 10; }
    else
        { A = pow(12,2); }

        a.     1250
        b.     2500
        c.     0
        d.     12500
        e.     144
 
 


Objective: Prepare for exam.
Last revision: October 3, 1999 at 10:30 am