Free Online Flashcard Deck

08 Objects and Encapsulation Free Online FlashCards

Study 08 Objects and Encapsulation with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is the difference between a Java class and an object?

Back

A class is a definition or blueprint; an object is a distinct instance created from that class.

02
Front

What three characteristics define an object?

Back

An object’s state is its stored data, behavior is supplied by its methods, and identity distinguishes it from other instances.

03
Front

What is a field in Java?

Back

A field is a variable declared inside a class; instance fields normally give each object its own stored state.

04
Front

What does an instance method operate on?

Back

An instance method operates on a particular object and can use or modify that object’s instance fields.

05
Front

What is a Java constructor?

Back

A constructor initializes a newly created object. It has the class’s name and no return type, not even `void`.

06
Front

What does the `new` operator do?

Back

The `new` operator creates an object by executing a constructor call; the resulting reference can be stored in a variable.

07
Front

How is an instance method invoked?

Back

The dot operator invokes an instance method through a reference, such as `account.deposit(40.00)`.

08
Front

What does `this` refer to in an instance method?

Back

Inside an instance method, `this` refers to the object on which the method was invoked.

09
Front

What is constructor overloading?

Back

Constructor overloading provides multiple constructors with different parameter lists, allowing several valid ways to create an object.

10
Front

What happens when `alias = original` is assigned?

Back

Assigning one reference to another copies the reference, not the object, so both variables can identify the same object.

11
Front

How does primitive assignment differ from reference assignment?

Back

Assigning one primitive variable to another copies the value, so later changes to one variable do not change the other.

12
Front

What does `null` mean for a Java reference?

Back

`null` means a reference refers to no object. Calling an instance method through it causes a `NullPointerException`.