Free Online Flashcard Deck

Java Class Design Essentials Free Online FlashCards

Study Java Class Design Essentials 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 class and an object?

Back

A class is a blueprint for creating objects; an object is a particular instance created from that class.

02
Front

How does an instance variable differ from a local variable?

Back

An instance variable belongs to an object and persists with it; a local variable exists only inside the method or constructor where it is declared.

03
Front

What default values does Java assign to uninitialized instance variables?

Back

Uninitialized numeric instance variables default to 0 or 0.0, booleans to false, and reference types such as String to null.

04
Front

What rules identify a Java constructor?

Back

A constructor has the class’s name, no return type, runs when new creates an object, and may receive parameters.

05
Front

What makes two constructors overloaded?

Back

Constructor overloading means defining multiple constructors in one class with different parameter lists, varying in number or type.

06
Front

When does Java stop supplying an automatic no-argument constructor?

Back

If a class declares any constructor, Java does not automatically provide a no-argument constructor. Write one explicitly if it is needed.

07
Front

What does this(...) do inside a constructor?

Back

The call to this(...) invokes another constructor in the same class and must be the first statement in the calling constructor.

08
Front

How do accessor and mutator methods differ?

Back

An accessor, or getter, returns information without changing state. A mutator, or setter, changes the object’s state, potentially after validation.

09
Front

What is encapsulation in class design?

Back

Encapsulation combines data with its operations while restricting direct access, commonly using private fields and public methods that validate changes.

10
Front

What does this refer to in an instance method?

Back

In an instance method or constructor, this refers to the current object—the object whose code is executing.

11
Front

Why write this.name = name in a constructor?

Back

In this.name = name, this.name is the instance variable and name is the parameter. The qualification prevents the parameter from being assigned to itself.

12
Front

How do static and instance variables differ?

Back

A static variable has one shared copy for the class, whereas an instance variable has a separate copy in every object.