Free Online Flashcard Deck

2 Classes and Objects Free Online FlashCards

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

12 cards
01
Front

What is a class in object-oriented programming?

Back

A class is a programmer-defined type that specifies the structure and behavior its objects will have.

02
Front

What is an object, or instance?

Back

An object is a concrete runtime value created from a class; it is also called an instance of that class.

03
Front

What does instantiation mean?

Back

Instantiation is the process of creating an object from a class.

04
Front

What is an attribute?

Back

An attribute is a named value associated with a class or object, such as `checking.balance`.

05
Front

What does an object's state describe?

Back

An object's state is the collection of its attribute values at a particular moment.

06
Front

What is a method?

Back

A method is a function associated with a class that defines an operation an object can perform or have performed on its behalf.

07
Front

What is the role of `self` in a Python instance method?

Back

In Python, an instance method conventionally receives the instance as its first parameter, usually named `self`; Python supplies it automatically for an object call.

08
Front

How do class and instance attributes differ?

Back

A class attribute is shared by a class or its instances, while an instance attribute belongs to one particular object.

09
Front

Why can mutable class attributes be dangerous?

Back

A mutable class attribute, such as a list or dictionary, is shared, so a change through one instance can be visible through other instances.

10
Front

What does Python's `__init__()` do?

Back

In Python, `__init__()` is an initializer called automatically after a new instance is created to establish its initial state.

11
Front

What identifies a Java constructor?

Back

A Java constructor has the same name as its class and has no return type; it is invoked during object creation.

12
Front

How do object identity and equality differ?

Back

Identity asks whether two references designate the exact same object; equality asks whether their values compare as equal.