Objects and Classes Flashcards

1
Q

Object-oriented programming enables you to develop large-scale ________ and _______ effectively.

A

software and GUIs

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

A class defines the properties and behaviors for _________.

A

objects

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

An object represents an entity in the real world that can be distinctly ________.

A

identified

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

What is Object-oriented programming (OOP)?

A

It’s an approach to programming that involves organizing objects and their behavior into classes of reusable components.

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

An objects has both a ______ and _______.

A

state and behavior.

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

A Python class uses _______ to store ____ _____ and defines ______ to perform ______. Additionally, a class provides a special type method, known as ______, which is invoked to create a new ______.

A

A Python class uses variables to store data fields and defines methods to perform actions. Additionally, a class provides a special type method. known as initializer, which is invoked to create a new object.

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

How do you define a class?

A

Define the initializer, create data fields, and define methods.

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

How do you create an object?

A

Use a constructor.

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

_______ is a template, blueprint, or contract that defines objects of the same type.

A

A class

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

The keyword __________ is required to define a class.

A

Class

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

Once a class is defined, you can create objects from the class with a ________. The ________ does two things:

It creates an _____ in the memory for the ______.

It invokes the class’s ______ method to initialize the object.

A
constructor
constructor
object
class
\_\_init\_\_
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The syntax for a constructor is:

A

ClassName(arguments)

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

What is the name of the initializer method?

A

__init__

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

________ is used to create an object.

A

A constructor

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

An object is an instance of a __________.

A

class

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

What is the object member access operator for?

A

The object member access operator is the dot (.).

17
Q

The first parameter in the initializer method is named self by convention. What is the role of self?

A

The self refers to the object itself. Through self, the members of the object can be accessed.

18
Q

What is a UML diagram?

A

A graphical notation for describing classes and their relationships

19
Q

What are the benefits of data hiding? How is it done in Python?

A

Two benefits: (1) for protecting data and (2) for easy to maintain the class.In Python, private data fields are defined with two leading underscores.

20
Q

How do you define a private method?

A

Add two underscores as the prefix for the method name.

21
Q

____ _____ in classes should be hidden to prevent data tampering and to make classes easy to maintain.

A

Data fields