OOP Flashcards

1
Q

What is Enumeration?

A

A type of class that creates a user-defined data type

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

Open Closed Principle

A

Classes can be extended, but not modified. It is violated if you will need to modify the class to handle an inheriting class

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

Abstract Class

A

Cannot instantiate an object but can only be used as a base class.

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

Composition

A

Form of association between classes where one class (the composite or whole) contains one of more objects of other classes (the components or parts).

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

What type of relationship does composition represent? As opposed to what?

A

“Has-a” - “Is-a”

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

Singleton Pattern

A

Ensures that a class has only one instance and provides a global point of access. Used when having multiple instances could lead to inconsistencies and management issues

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

Abstract Factory

A

Creational design pattern. Provides an interface for creating families of related or dependent objects without specifying their concrete classes.

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

Data Hiding

A

Refers to masking a classes internal operations and only providing an interface through which other entities can interact with the class without being aware of what is happening within.

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

Encapsulation

A

Use to achieve data hiding. Refers to binding data and the methods to manipulate that data together in a single unit (class).

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

Is it a good convention to declare all variables of a class private?

A

Yes, this restricts direct access by the code outside of the class. Use public methods such as getters and setters to grant access to internal variables.

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

Abstraction

A

Technique that focuses on revealing only the necessary details of a system and hiding irrelevant information to minimize complexity.

“Show what an object does and hide how it does it”

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

Polymorphism

A

Allows an object to have several different forms and behaviors.

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

Dynamic Polymorphism

A

AKA runtime polymorphism. Defines methods with same name, return type and parameters in base class and derived classes. Subclasses will need to override if there is something specific it needs to do.

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

Static Polymorphism

A

AKA compile-time polymorphism. Achieved by method or operator overloading.

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

Operator Overloading

A

”+” can be different depending on the data type. It will concatenate a string, but add two integers

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

Is static polymorphism or dynamic polymorphism more performant?

A

Static, because the binding is being done at compile time.

17
Q

Steps to drawing a sequence diagram

A
  1. Identify the use case
  2. Identify the Actors and Objects
  3. Identify the order of actions
  4. Create the diagram
18
Q

Fragment Frame

A

Allow us to represent conditional actions or loop sequences on a sequence diagram.

19
Q

Steps to drawing an activity diagram

A
  1. Determine the actions of the system
  2. Determine the actors and their roles, and list them out
  3. Find the flow of each activity
  4. Create the diagram
20
Q

Single Responsibility Principle (SRP)

A

Each class should be responsible for a single part or functionality of the system

21
Q

Open Closed Principle (OCP)

A

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

A system should improve easily without changing the code core.

22
Q

Liskov Substitution Principle (LSP)

A

Objects of a superclass should be replaceable with objects of its subclasses without breaking the system

23
Q

Interface Segregation Principle (ISP)

A

Make fine-grained interfaces that are client specific

24
Q

Dependency Inversion Principle (DIP)

A

High level modules are not dependent on low-level modules.

25
Q

Creational Design Patterns

A

Used to provide a mechanism for creating objects in a specific situation without revealing the creation method.

26
Q

Structural Design Patterns

A

Concerned with class/object composition and relationships between objects. Let us add new functionalities to objects so that restructuring some parts of the system does not affect the rest.

27
Q

Behavioral Design Patterns

A

Concerned with communication between dissimilar objects in a system. Ensure information synchronization

28
Q
A