class Flashcards

1
Q

is a programming Paradigm based on concept of “object”

A

object oriented programming

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

each object represents an entity with —– and ——-

A

attributes(data) and methods (behavior)

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

Key OOP principles:

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

is a blueprint or template for creating objects in Python. It
encapsulates data (attributes) and functions (methods) that define
the properties and behavior of the objects.

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

does not occupy
memory until an object(instance) is created from it.

A

A class

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

Key concepts in a class using Python:

A

Attributes (Fields/Properties): These are variables that belong to the class.
They represent the data or state of an object. There are two types of attributes:
Instance attributes: Unique to each object.
v/ Class attributes: Shared across all instances of the class.
Methods: These are functions that belong to the class and define the
behaviors of the object. They typically operate on the object’s attributes.
Constructor (_init method): This is a special method in Python used to
initialize the attributes ofa class when an object is created.
Object (Instance): An object is an instance of a class. When a class is
defined, no memory is allocated until an object is created from it.

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

These are variables that belong to the class. They represent the data or state of an object.

A

Attributes (Fields/Properties):

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

There are two types of attributes:

A

Instance attributes: Unique to each object.
Class attributes: Shared across all instances of the class.

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

Unique to each object.

A

Instance attributes:

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

Shared across all instances of the class.

A

Class attributes:

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

These are functions that belong to the class and define the
behaviors of the object. They typically operate on the object’s attributes

A

Methods:

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

This is a special method in Python used to initialize the attributes of a class when an object is created.

A

Constructor (_init method):

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

When a class is
defined, no memory is allocated until an object is created from it.

A

Object (Instance):

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

why use classes in OOP:

A

Encapsulation: Classes allow you to bundle data (attributes)
and methods (functions) that operate on the data into one unit.
Reusability: You can create multiple objects (instances) from
a single class.
Inheritance: Classes can inherit attributes and methods from
other classes, promoting code reuse.
Polymorphism: Objects of different classes can be treated as
instances of the same superclass, even if they behave differently

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

Classes allow you to bundle data (attributes)
and methods (functions) that operate on the data into one unit.

A

Encapsulation:

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

You can create multiple objects (instances) from
a single class.

A

Reusability:

17
Q

Classes can inherit attributes and methods from
other classes, promoting code reuse.

A

Inheritance:

18
Q

Objects of different classes can be treated as
instances of the same superclass, even if they behave differently

A

Polymorphism:

19
Q

is a special method called init ( ) in Python.

A

A constructor

20
Q

It initializes an object’s attributes when the object is created.

A

A constructor

21
Q

It is automatically invoked when an object is instantiated.

A

A constructor

22
Q

is the concept of bundling data (attributes) and
methods that operate on the data within a class. It restricts direct
access to some attributes by using private (or protected)
members.Promotes data hiding and improves security by
preventing unauthorized access.

A

Encapsulation

23
Q

allows one class (child class) to inherit attributes and
methods from another class (parent class).lt promotes code reuse
by letting new classes adopt behaviors of existing ones.Child
classes can also override parent class methods.

A

Inheritance

24
Q

allows objects of different classes to be treated as
objects of a common superclass. It enables using a single
method across different object types.

A

Polymorphism

25
Q

Types of polymorphism:

A

Method overriding: Subclasses can provide their own
implementation of methods inherited from the parent class.
Method overloading (not directly supported in Python but
can be simulated using default parameters).

26
Q

Subclasses can provide their own
implementation of methods inherited from the parent class.

A

Method overriding:

27
Q

(not directly supported in Python but
can be simulated using default parameters).

A

Method overloading