Topic D OOP

IB Computer Science Option D Flashcards (OOP)

Question

Answer

What is a class?

A template that defines attributes and methods of objects.

What is an object?

An instance of a class containing data (state) and behavior (methods).

What is encapsulation?

Bundling of data and methods, restricting direct access using private fields and public methods.

What is inheritance?

Mechanism where a subclass inherits attributes and methods from a superclass.

What is polymorphism?

Ability of methods to behave differently based on the object that calls them (method overriding).

What does the static keyword do?

Declares attributes/methods that belong to the class rather than instances.

What does UML stand for?

Unified Modeling Language

Symbol for inheritance in UML?

Solid line with a hollow triangle pointing to superclass.

What does aggregation mean?

A whole-part relationship where the part can exist independently.

What does composition mean?

A whole-part relationship where the part cannot exist independently.

How do you declare an array of House objects?

House[] wishList = new House[10];

How do you check if an array element is not null?

if (wishList[i] != null)

What is a method signature?

Method name + parameter types (e.g., search(String name))

What is method overloading?

Two or more methods with the same name but different parameter lists.

What is the purpose of a constructor?

Initializes a new object’s attributes when it is created.

How do you sort House objects by price?

Arrays.sort(allHouses, Comparator.comparingInt(House::getPrice));

What is an Abstract Data Type (ADT)?

Data type that hides implementation details and exposes operations (insert, delete, etc.)

Key feature of linked list ADT?

Nodes linked dynamically with pointers to next node.

What does the enList method do?

Adds a new node to the end of a linked list.

Advantage of encapsulation?

Improves maintainability and security by restricting access to internal data.

What is the difference between aggregation and composition?

Aggregation: parts can exist independently. Composition: parts cannot exist independently.

Why use inheritance?

To promote code reuse and logical hierarchy of classes.

What are getter and setter methods?

Methods to retrieve (get) or update (set) private attributes.

How do you prevent NullPointerException?

Always check if object reference is not null before access.