Classes and Encupsulation Flashcards

1
Q

3 Fundamental Principles of Object-Oriented Programming

A
  1. Encapsulation.
  2. Inheritance.
  3. Polymorphism.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Encapsulation

A

Concept of hiding values or state of data within a class, limiting the points of access.

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

Inheritance

A

The practice of creating a hierarchy for classes in which descendants obtain the attributes and behaviors from other classes.

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

Polymorphism

A

The ability for a code to take on different forms. In other words, it’s the ability to treat classes generically and get specific results.

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

Benefits of Object-Oriented Programming

A
  1. A natural way of expressing real-world objects in code.
  2. Modular and reliable, allowing changes to be made in one part of the code without affecting another.
  3. Discrete units of reusable code.
  4. Units of code can communicate with each other by sending and receiving messages and processing data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Encapsulation characteristics

A
  1. The packaging of data and functions into a single component.
  2. Hiding the implementation details of a class to prevent other parties from setting the data to an invalid or inconsistent state and also to reduce coupling.
  3. Enables classes to be highly cohesive, meaning to have a clearly defined purpose.
  4. Implemented by using access modifiers that let the compiler know which data members and methods can be accessed and modified by others.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Coupling

A

Coupling refers to the degree of direct knowledge each component of a system or application has of elements that it needs to use.

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

Loose Coupling

A

An approach to connect components that depend on each other with the least knowledge possible.

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

Access modifiers

A

Visibility of classes, member methods, and variables
Defines who can use a class, method, or variable.
- public
- private

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

Variables

A

Should always be private. If the others need access to them, then they should be given access via public getters and setters.

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

Methods

A

Should be public only if they are meant for use by the users of our class.

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

Classes

A

Is a blueprint or model that defines state with fields (variables) and behavior with methods.

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

Methods

A

Reusable block of code. Define object’s behaviors.

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

OOP

A

Object-Oriented Programming

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

Overloaded methods

A

Methods with the same name and return type, and a different set of parameters.

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

Constructor

A

Is a special method that runs every time a new object is instantiated.

17
Q

Function Overriding

A

Provide own functionality for the subclasses’ method.

18
Q

Final

A

A keyword that allows the variable to be assigned once, and after set, it cannot be reassigned.

19
Q

Static

A

Static members belong to the class. Static methods can be invoked without creating an instance of the class.