Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Review Questions

1.1Which statement about methods is true?

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.2Which statement about objects is true?

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.

  5. An object is a variable.

1.3Which is the first line of a constructor declaration in the following code?
public class Counter {                                             // (1)
  int current, step;
  public Counter(int startValue, int stepValue) {                  // (2)
    setCurrent(startValue);
    setStep(stepValue);
  }
  public int getCurrent()            { return current; }           // (3)
  public void setCurrent(int value)  { current = value; }          // (4)
  public void setStep(int stepValue) { step = stepValue; }         // (5)
}

Select the one correct answer.

  1. (1)

  2. (2)

  3. (3)

  4. (4)

  5. (5)

1.4Given 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.5Which statement about instance members is true?

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.6How do objects communicate in Java?

Select the one correct answer.

  1. They communicate by modifying each other’s fields.

  2. They communicate by modifying the static variables of each other’s classes.

  3. They communicate by calling each other’s instance methods.

  4. They communicate by calling static methods of each other’s classes.

1.7Given 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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial