Object Oriented Programming Flashcards

To have some amount of mastery in object oriented programming (34 cards)

1
Q

What is OOP (Object Oriented Programming)?

A

Object-Oriented Programming (OOP) is a programming approach that organizes code into reusable software entities called objects. These objects encapsulate data (attributes) and the functions (methods) that operate on that data

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

What is modularity?

A

Modularity is the concept of breaking down a complex system into smaller, independent, and interchangeable parts called modules

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

What is Procedural programming?

A

Procedural programming is a programming paradigm that uses procedures (or functions and subroutines) to perform specific tasks, breaking down a program into a series of steps and instructions

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

What is Inheritance?

A

The capabilities of a class to derive properities or characteristics from another class is known as inheritance. The properties of Class A can be shared or inherited by another Class name B without the need to write all of Class A propeties to B agian. This reduce redundancy in code.

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

What is Encapsulation?

A

Encapsulation is the wrapping of data under a single unit or keeping data safe inside an object, and it can only be changeed in control ways. In Encapsulation Class A cannot accesss the properites or data in Class B. The data in Class A is hidden from Class B which is why it’s also caled data-hiding.

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

What is Data Abstraction?

A

Data abstraction shows the essential information while hiding the rest. it include providing only essential information to the outside world and hiding the background implementation

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

A computer does two thing, what are they?

A

A computer simply processes calculations and stores them

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

What were the earliest set of computers?

A

The earliest set of computers were set to be fixed prorammed machines or computers meaning they were only made for specific purposes typicall for mathematical calculation. An example of a fixed programmed machine today is the calculaor

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

What is a class?

A

A class is a
blueprint
for creating objects. It defines a structure that binds both
data
(attributes) and
methods
(functions) into a single unit

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

What is the truly first Modern Computer?

A

Manchest Mark ii. A stored program computer

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

WHat is flow of control

A

Is the order in which a program execute instructions or statement by using conditionals and loops.

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

What is one weakness of python?

A

Weakness in static semantic checking so it’s not optimal for programs with high reliability constraints.

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

What is an Object

A

An object is an
instance
of a class. It represents individual entities that have
state
(attributes)
and
behavior
(methods). Each object created from the same class will have unique values for
its attributes but share the same structure and behavior

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

waht is the purpose of the init function?

A

_init__ function in Python is to initialize a new object when an instance of a class is created. It acts as the constructor for the class,

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

What is the purpose of the .self function in python

A

n Python, self is a convention used within class methods to refer to the instance of the class on which the method is being called

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

What are methods?

A

Functions defined within a class to represent behaviors

13
Q

What are constructors in python?

A

A special method within a class that is automatically called when an object of that
class is created

14
Q

What are attributes?

A

Attributes
are like the characteristics or properties of an object. They define what an object is
and what it can do. There are two main types

15
Q

Define the instance Attribute?

A

Instance Attributes:
Belong to individual objects.
Defined within the
__init__
method.
Accessed using
self.attribute_name

An instance attribute is a variable that belongs exclusively to a specific instance (object) of a class. Unlike class attributes, which are shared by all instances of a class, instance attributes store data that is unique to each individual object.

16
Q

What are class attribute?

A

Shared by all instances of a class.
Defined directly within the class.
Accessed using
ClassName.attribute_name
or
self.attribute_name
.

16
Q

What is an instance method?

A

Belong to individual objects.
Take
self
as the first parameter.
Can access both instance and class attributes

An instance method is a function that is defined within a class and operates on a specific object (an “instance”) of that class.

17
Q

What is a class method?

A

Belong to the class itself.
Decorated with the
Take
@classmethod
decorator.
cls
as the first parameter.
Can only access class attributes.
A class method in Python is a type of method that operates on the class itself, rather than on an instance of the class. It is defined within a class and is typically used to interact with class-level attribute

18
Q

Why do we use methods?

A

Encapsulation:
Methods help encapsulate the behavior of an object within the class,
making it more modular and easier to maintain.

Reusability:
You can define methods that can be used by multiple objects of the
same class, promoting code reusability.

Abstraction:
Methods allow you to hide the implementation details of an object’s
behavior, providing a simpler interface for users

19
Q

What is a getter method?

A

A getter method is used to retrieve the value of an attribute

20
what is a setter mehtod?
A setter method is used to set or modify the value of an attribute. It provides a controlled way to update an attribute's value,
21
What is the key idea behind encapsulation and why?
Encapsulation restrict direct access to certain parts of an object’s data and only allows interaction through specific methods, usually called getters and setters Why : This helps to protect the internal state of an object by making sure it cannot be changed or accessed directly in an uncontrolled way
22
What are access modifiers?
In Python, access modifiers control how the attributes and methods of a class can be accessed. These modifiers are used to define the visibility and scope of class members
23
What are the three level of access modifiers?
Python offers three levels of access modifiers: public , protected private
23
What are the significance of Access Modifiers
Protect sensitive data (encapsulation) Prevent accidental modification Define visibility (public, protected, private
24
What are publice access modifiers?
public member (variable or method) is accessible from anywhere — both inside and outside the class. By default, all class members in Python are public unless specified otherwise.
25
What is a protected Access Modifiers?
A protected member is intended to be accessed only within the class and its subclasses, but not enforced strictly — it’s more of a convention in Python. Defined by one underscore _ before the name.
26
What are private Access Modifiers?
A private member is completely hidden from outside the class. You cannot access it directly — only from inside the class. ➤ Defined by two underscores __ before the name.
27
28
Why do we use getters and setters?
🛡️ Encapsulation Protects data from being changed directly. ✅ Validation Allows checking before changing a value. ⚙️ Control Lets you decide how attributes are set or retrieved. 🔒 Security Hides sensitive data and exposes only what’s needed.