Review Questions

graphics/rq_icon.gif

1.1

Which statement is true about a method?

Select the one correct answer.

  1. A method is an implementation of an abstraction.

  2. A method is an attribute defining the property of a particular abstraction.

  3. A method is a category of objects.

  4. A method is an operation defining the behavior for a particular abstraction.

  5. A method is a blueprint for making operations.

1.2

Which statement is true about an object?

Select the one correct answer.

  1. An object is what classes are instantiated from.

  2. An object is an instance of a class.

  3. An object is a blueprint for creating concrete realization of abstractions.

  4. An object is a reference to an attribute.

  5. An object is a variable.

1.3

Which line contains a constructor in this class definition?

public class Counter {                                               // (1)
    int current, step;

    public Counter(int startValue, int stepValue) {                  // (2)
        set(startValue);
        setStepValue(stepValue);
    }

    public int get() { return current; }                             // (3)

    public void set(int value) { current = value; }                  // (4)

    public void setStepValue(int stepValue) { step = stepValue; }    // (5)
}

Select the one correct answer.

  1. Code marked with (1) is a constructor.

  2. Code marked with (2) is a constructor.

  3. Code marked with (3) is a constructor.

  4. Code marked with (4) is a constructor.

  5. Code marked with (5) is a constructor.

1.4

Given that Thing is a class, how many objects and how many reference variables are created by the following code?

Thing item, stuff;
item = new Thing();
Thing entity = new Thing();

Select the two correct answers.

  1. One object is created.

  2. Two objects are created.

  3. Three objects are created.

  4. One reference variable is created.

  5. Two reference variables are created.

  6. Three reference variables are created.

1.5

Which statement is true about an instance method?

Select the one correct answer.

  1. An instance member is also called a static member.

  2. An instance member is always a field.

  3. An instance member is never a method.

  4. An instance member belongs to an instance, not to the class as a whole.

  5. An instance member always represents an operation.

1.6

How do objects pass messages in Java?

Select the one correct answer.

  1. They pass messages by modifying each other's fields.

  2. They pass messages by modifying the static variables of each other's classes.

  3. They pass messages by calling each other's instance methods.

  4. They pass messages by calling static methods of each other's classes.

1.7

Given the following code, which statements are true?

class A {
    int value1;
}

class B extends A {
    int value2;
}

Select the two correct answers.

  1. Class A extends class B.

  2. Class B is the superclass of class A.

  3. Class A inherits from class B.

  4. Class B is a subclass of class A.

  5. Objects of class A have a field named value2.

  6. Objects of class B have a field named value1.



     
    ASPTreeView.com
     
    Evaluation has ґАКПБАЩТЧСНexpired.
    Info...