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.

Donation Page

Support Our Work

Do you appreciate the value this website provides? If so, please consider donating to help keep it running. Your donation will go a long way in helping us continue to provide the same quality of content and services. Every bit helps, and your support is greatly appreciated. Thank you for your generosity.