Name: ___________________________                                                                   Pop Quiz 2/22/08

 

Straight from last semester’s Exam (which is at learn@UW):


For the next six questions, consider the following complete class definition:

public class Demo {
    private int info;
    private static double data;
    public static final char letter = 'x';
    public String name;

    public Demo(int a, double b, String c) {
        info = a;
        data = b;
        name = c;
    }

    public int method1(int d) {
        int e = 14;
        return d * e;
    }

    public static void method2() {
        double f = 3.0;
        int g = 7;
        Demo item = new Demo(1, 2.3, "4");
        // CODE
    }
}


Consider inserting a line of code immediately after the line marked //CODE . Which of the following
would result in code that would compile if the line of code is inserted at the place indicated? The
answer choices are given below. The choices may be used zero or more times.
A. Yes; the code would compile.
B. No; the code would not compile.

14)_____ method1(10);

15)_____ data = 1.4;

16)_____ Demo.letter = 'q';

17)_____ this.info++;

18)_____ f = b + 4.2 * data;

19)_____ item.name = "me";