Chapter 10 (Object Oriented Programming Pt.1) Flashcards
a programming model that focuses on an application’s components (and the data and methods used in those components)
object oriented programming (OOP)
Items that a program will manipulate
Objects
a group or collection of objects with common attributes
class
an object is one _______ of a class.
instance / instantiation
the actions that can be taken on an object
methods
this always begins with an uppercase letter and uses Pascal casing
ClassName
the characteristics of an object
attributes
In OOP, ______ are also objects!
events
Every object instantiated from a given class possesses the same _________.
methods
a relationship that describes an object being an instance of a more general class
Is-a relationship
the data components of a class that belong to every instantiated object in that class
instance variables
These will oftentimes alter, use, or retrieve the attributes
Methods
Every object is an _______ of a more general class
instance
a program or class that instantiates objects of another prewritten class
class client
What is another word for instance variable(s)?
Field(s)
The set of all the _______ or _______ of an object’s instance variables is its state.
values, contents
What is another word for class client?
class user
The designation of a _____ is to help distinguish these variables from other variables you might use.
field
In a GUI operating environment, you may write applications that have prewritten components from classes with names like “Window” and “Button”. This would be an example of a…
class user/class client
When procedures operate differently using various objects, but the procedure is still called the same thing, this is an exmaple of…
Polymorphism
Object-oriented languages understand methods in context of their _______, just as people understand verbs in context of their ______.
objects, nouns.
the process of acquiring the traits of one’s predecessors
Inheritance
the process of combining all of an object’s attributes and methods into a single package
Encapsulation
Information Hiding is a concept that other classes should not alter an object’s ________, and that only the methods of an object’s own class should have that privelege.
attributes
________ ______ should only be allowed to make a request that an attribute be altered.
Outside classes
What are the five integral components of OOP?
- Class.
- Objects.
- Polymorphism.
- Inheritance.
- Encapsulation.
What is another phrase for information hiding?
Data hiding
This describes a group or collection of objects with common attributes.
a Class
A class definition must have ______
a name.
______ and ______ are portions of a class definition that are NOT required.
Data, methods
______ and ______ are portions of a class definition that are NOT required.
Data, methods
A set of program statements that lists the characteristics of each object and the methods each object can use.
Class definition
A larger section of ______ is reserved than when declaring a simple variable / using primitive data types, because a Class may contain several fields.
memory
This type’s data is private and can be accessed only through methods.
Abstract Data Type (ADT)
simple numbers and characters
primitive data types
Programmers use these to plan or illustrate class features, and to describe a ____ to non-programmers.
Class diagram, class
What does this notation mean?:
setLastName(name : string) : void
Give 3 statements about it.
- The method name is setLastName()
- It takes a single string parameter named “name”.
- It returns nothing; hence, the “void”.
These set or change the values of data fields defined within a class
Set method(s)
What is another phrase for a “set method”?
Mutator method
True or False: You can pass variables or named constants the methods, instead of literal constants, as long as they are the correct data type.
True
These provide a way to set a field value using a simpler syntax
Property/properties
The purpose of a ___ _____ is to return a value from the class to a client
Get method
Accessor method, work method, help method, and facilitator are all synonyms for…
Get method
True or False: You can declare an object locally within a method?
True
The adjective that defines the type of access outside classes will have to the attribute or method
access specifier
(-) vs (+)
Private access vs public access
_______ methods act as an interface to the private ____ _____; this is the KEY TENET OF ENCAPSULATION AND DATA HIDING.
Public, data fields
A method that works appropriately with different objects
Instance method
a “this reference” is implicitly passed to instance methods, and that reference becomes a _______ to each instance method.
parameter
True or False: A this reference must be explicitly declared.
False. It is an automatically created variable that holds the address of an object, and it is passed to an instance method whenever the method is called.
Static methods do not require…
a this reference
Static methods are the same thing as _____ methods.
class
Methods that exist to be used with an object; these methods act differently depending on the object used to call them.
Nonstatic method(s)
Methods for which no object needs to exist
Class methods
Methods in a class are generally ______ by default.
Nonstatic
Can you pass an object to a method?
Yes
Can you return an object from a method?
Yes
True or False: You can use arrays of objects similar as your would with any primitive data type.
True
When data cannot be accessed by any method that is not a part of the class; this has to be specified
Private access
When other programs and methods outside of the class can get access to private data.
Public access
Main() is virtually always…
public
A type that is not built into a language, but is created by an application’s programmer
a user-defined type OR a programmer-defined type
This means the same thing as a field.
an instance variable
Which of the following does not belong with the others?:
a. instance variable
b. attribute
c. object
d. field
c. object
Encapsulation means that all the _______ and _______ are grouped together.
fields, methods
Are methods and data necessary for a class?
No, only the class name.
A _____ _______ provides an overview of a class’s data and methods.
class diagram
Methods for which no objects need to exist; these are not instance methods, and they do not receive a this reference.
static methods
Inheritance is a type of…
is-a relationship.
The designation of a _____ (in a class) is to help distinguish these from other variables you might use throughout the program.
field
The set of all the values or contents of an object’s instance variables is its ______.
state
True or False: Every object instantiated from a given class possess the same methods.
True
True or False: Declaring a class creates actual objects
False. A class is just an abstract description of what an object will be if any objects are actually instantiated.
After declaring an object, that object contains all of the ____ _____ and _______ defined in its class.
data fields, methods
A class is the ____ ____ of its objects. This is why programmer-defined types are considered Abstract Data Types (ADT)
data type
In a class diagram, the middle section contains the…
names and data types of the attributes.
Programmers use these to plan/illustrate class features before they use wireframes.
Class diagram
The purpose of a set method / _______ method, is to set or change the values of data fields as defined within the class.
mutator
True or False: When an attribute is contained in the same class as a method, the method has access to the field and can alter it.
True
A get method or ________ method’s purpose is to return a value from the class to a client.
accessor - facilitator - help - work
A method that works appropriately with different objects because a “this reference” is implicitly passed to it.
Instance method
A “this reference” is a ________ to each instance method.
parameter
This is an automatically created variable that holds the address of an object that is passed to an instance method whenever the method is called.
This reference
True or False: You can use this references with local variables that are parameters to instance methods, or variables that are declared within method bodies.
False, a this reference can only be used with identifiers that are part of the class definition.
this.fieldName is an example of a…
this reference
Static / class methods do not require a this reference because they do not use any ____ _____ from a class; thus, it does not matter which object calls it.
data fields
A class method is a _______, because no objects need to exist for the method to work, as it does not use any data fields from the class.
misnomer
Methods in a class are generally ________ instance methods by default.
nonstatic
Object attributes or data
Fields
the data components that belong to every instantiate object; similar to a field
instance variables
Class methods (i.e. static methods) are NOT an ________ method, as they do NOT receive a this reference
instance