Object Oriented Programming Flashcards
Learn about how to create and use object oriented programming in Python
1
Q
An object is an instance and has:
A
- a type
- an internal data representation
- each instance is a particular type of object
2
Q
Objects
A
- A data abstraction that capture
- Can create new instances of objects
- Can destroy objects
3
Q
Data abstraction captures
A
- internal representation
- interface for interacting with objects through methods (procedures)
4
Q
Creating a class
A
- defining the class name
- defining the class attributes
5
Q
Using the class
A
- creating new instances of objects
- doing operations on the instance
6
Q
Advantage of OOP
A
- Bundle data into packages together with procedures (functions)
- Divide-and-conquer development
- Classes make it easy to reuse code
7
Q
Divide-and-conquer development
A
- implement and test behavior of each class separately
- increase modularity reduces complexity
- inheritance allows sub-classes to redefine or extend a subset of a super-class behavior
8
Q
Method is
A
A function that works only with THIS class
9
Q
More about methods
A
Python always passes the actual object as the first argument to use as ‘self’
10
Q
The “.” operator is used to:
A
Access any attribute:
- a data attribute of an object
- a method of an object
11
Q
Class is
A
A blueprint created by a programmer for an object
12
Q
Object is
A
An instance of a class
13
Q
Power of OOP
A
- bundle objects together
- use abstractions (how to implements vs. how to use)
- build layers of object abstractions
- create own classes of objects
14
Q
Implementing class vs using class
A
write code from two different perspectives
15
Q
Implementing an object
A
- define the class
- define the data attributes
- define methods