OOP Flashcards

(26 cards)

1
Q

Define encapsulation.

A

The bundling of data and methods that operate on that data within a single unit, or class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is inheritance in OOP?

A

A mechanism where a new class derives properties and behaviors from an existing class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or false: Polymorphism allows methods to do different things based on the object.

A

TRUE

Polymorphism enables a single interface to represent different underlying forms (data types).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: Abstraction is the concept of hiding _______ details.

A

complex implementation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define class.

A

A blueprint for creating objects, defining properties and methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an object in OOP?

A

An instance of a class that contains data and methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or false: Interfaces can contain method implementations.

A

FALSE

Interfaces only declare methods without providing implementations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define method overriding.

A

A feature that allows a subclass to provide a specific implementation of a method already defined in its superclass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is method overloading?

A

Defining multiple methods in the same class with the same name but different parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Fill in the blank: Static binding occurs at _______ time.

A

compile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define dynamic binding.

A

The process of linking a procedure call to the code to be executed only at runtime.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a constructor?

A

A special method invoked when an object is created, initializing its properties.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or false: Destructors are used to free resources when an object is no longer needed.

A

TRUE

Destructors are called automatically when an object goes out of scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Fill in the blank: Composition is a ‘has-a’ relationship, while inheritance is a ‘______’ relationship.

A

is-a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define polymorphism.

A

The ability of different classes to be treated as instances of the same class through a common interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is aggregation?

A

A form of association where one class contains references to objects of another class.

17
Q

True or false: Abstract classes can be instantiated.

A

FALSE

Abstract classes are meant to be subclassed and cannot create objects directly.

18
Q

Fill in the blank: Interfaces provide a way to achieve _______ in OOP.

A

multiple inheritance

19
Q

Define single responsibility principle.

A

A class should have only one reason to change, meaning it should have only one job.

20
Q

What is the open/closed principle?

A

Software entities should be open for extension but closed for modification.

21
Q

True or false: Liskov substitution principle states that objects of a superclass should be replaceable with objects of a subclass.

A

TRUE

This principle ensures that a subclass can stand in for its superclass.

22
Q

Fill in the blank: The interface segregation principle suggests that clients should not be forced to depend on _______ they do not use.

23
Q

Define dependency inversion principle.

A

High-level modules should not depend on low-level modules. Both should depend on abstractions.

24
Q

What is dynamic polymorphism?

A

Polymorphism resolved at runtime, typically through method overriding.

25
True or false: **Static polymorphism** is achieved through method overloading.
TRUE ## Footnote Static polymorphism occurs at compile time.
26
Fill in the blank: **Data hiding** restricts access to _______ within a class.
internal state