2.5.5 Using The Point Class
Question: What is an object in Java?
Answer: An object is something that contains both state and behavior.
Question: Which of the following best describes the relationship between a class and an object?
Answer: A class definition specifies the attributes and behavior of every object that will be made.
Question: Every class definition has each of the following EXCEPT
A name
Defined attributes
Defined behaviors to manipulate the state of the objects
Defined objects as copies of the class
Answer: Defined objects as copies of the class
Question: Consider this class definition of a Pineapple.
public class Pineapple
{
private boolean isRipe;
private String color;
private double weight;
// Rest of class goes here
}
When we use this class to create Pineapple objects, which of the following is guaranteed to be true?
Answer: Every Pineapple object will have the same attributes.
Question: What is a constructor in Java?
Answer: A constructor allows us to create a new instance of a class, usually initializing instance variables.