Object-Oriented Programming in Java - Quiz Explanation

The correct answers are indicated below, along with text that explains the correct answers.
 
1. What are the two common characteristics shared by all objects?
Please select the best answer.
  A. Methods and interfaces
  B. State and behavior
  C. Methods and messages
  The correct answer is B.
State and behavior are the two common characteristics shared by all objects. Methods, interfaces, and messages are all related to behavior.

2. What really happens when a message is sent to an object?
Please select the best answer.
  A. A method is called on that object.
  B. A member variable is set for that object.
  C. A text string is assigned to the object.
  The correct answer is A.
When a message is sent to an object a method is called on that object. Member variables are only set in response to a message if the called method sets them. Assigning a text string to an object is only possible if the object is of type String or a class derived from the String class.

3. When a class is based on another class, it inherits:
Please select the best answer.
  A. The data and methods for the class
  B. The methods and messages for the class
  C. Only the data for the class
  The correct answer is A.
When a class is based on another class, it inherits the data and methods for the class.

4. OOP promotes a way of programming that allows programmers to think in terms of:
Please select the best answer.
  A. Data
  B. Procedures
  C. Objects
  The correct answer is C.
OOP promotes a way of programming that allows programmers to think in terms of objects. Data is only part of the OOP equation; in OOP data is always coupled with methods. Procedures do not fit in with OOP; methods are the OOP equivalent of procedures.

5. What is a template, or specification, that defines a type of object?
Please select the best answer.
  A. A class
  B. A prototype
  C. A framework
  The correct answer is A.
A class is a template, or specification, that defines a type of object. Prototypes are function descriptions that aren't used in Java. A framework is a hierarchy of related classes.

6. What Java keyword do you use to define a class?
Please select the best answer.
  A. define
  B. new
  C. class
  The correct answer is C.
You use the class Java keyword to define a class. There is no define keyword in Java. The new keyword is used to create objects from classes.