Classes and Objects Flashcards

1
Q

The _______ keyword is used to define a class in Python.

A

class

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

An instance of a class is called an _________.

A

object

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

__________________ is the principle of restricting direct access to some attributes.

A

Encapsulation

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

The process where one class derives from another class is called _____________.

A

inheritance

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

The ability of a function to behave differently based on the object calling it is known as _________________.

A

polymorphism

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

A _______________ is a special method used for initializing objects in Python.

A

constructor

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

_______________ is the process of hiding implementation details and only showing the necessary functionality.

A

Abstraction

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

The method used to access private attributes in a class is called a __________.

A

getter

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

A ____________ is a class that inherits from another class.

A

subclass

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

Which of the following is NOT a pillar of OOP? a) Encapsulation
b) Compilation
c) Polymorphism
d) Inheritance

A

b) Compilation

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

What does the super() function do?
a) Creates an object
b) Calls the parent class constructor
c) Deletes an object
d) Defines an abstract method

A

b) Calls the parent class constructor

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

What is the purpose of the self keyword in Python classes?
a) Refers to the instance of the class
b) Calls the parent class constructor
c) Defines a static method
d) Hides class attributes

A

a) Refers to the instance of the class

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

Which OOP concept allows multiple classes to have methods with the same name?
a) Encapsulation
b) Abstraction
c) Polymorphism
d) Inheritance

A

c) Polymorphism

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

What is the primary purpose of inheritance in OOP?
a) To increase code duplication
b) To allow reusability of code
c) To make variables private
d) To hide methods

A

b) To allow reusability of code

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

Which of the following best describes abstraction?
a) Hiding unnecessary details
b) Preventing access to variables
c) Overriding methods
d) Allowing multiple inheritances

A

a) Hiding unnecessary details

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

Which keyword is used to define a class in Python?
a) object
b) define
c) class
d) function

17
Q

What is an instance method in Python?
a) A method that belongs to an instance of a class
b) A method that only belongs to a superclass
c) A method that can only be called once
d) A method that is declared as static

A

a) A method that belongs to an instance of a class

18
Q

What is the term used for creating an object from a class?
a) Instantiation
b) Abstraction
c) Overriding
d) Declaration

A

a) Instantiation

19
Q

What is the term for a class that cannot be instantiated and only serves as a base class?

A

Abstract class

20
Q

What keyword is used to inherit from another class in Python?

21
Q

What is the process of restricting direct access to an object’s attributes?

A

Encapsulation

22
Q

What is the method used to initialize an object’s attributes in Python classes?

23
Q

What is the term for an object’s ability to take many forms?

A

Polymorphism

24
Q

What is the technique of reusing code by creating a new class from an existing class?

A

Inheritance

25
Q

What is the act of creating an object from a class called?

A

Instantiation

26
Q

What Python module is used for implementing abstract classes?

A

abc module