OOP Overview Flashcards
Five basic concepts of Object Oriented Design:
classes and objects,
inheritance,
interfaces and methods,
encapsulation,
polymorphism.
A Maple (capital M) is a _______. We capitalize it because it’s the blueprint. When seeds drop and sprout, the growing maple tree is really an __________, or a type, of the Maple class. The growing maple tree is considered an _________, that is, an instance of a class.
class, instance, object
________________ is a fancy word to describe the protection, or hiding, of data. The power of ____________________ is that you can protect certain data in certain classes from being used.
Encapsulation, objected-oriented design
An __________ of a Maple class (a maple) will change colors in the fall. To do so it needs a __________, or a function that performs an action.
instance, method
An ___________ tells the object what it can do. For example, it tells a tree that it can grow.
interface
_____________ really means that the same thing can have different features.
polymorphism
An object-oriented design consists of periodical and publication data. The hierarchy of classes, from top to bottom is as follows: Publication -> Book -> Novel. If the Novel class gains all methods and fields from the Book class, this is an example of which of the concepts of Object Oriented Design?
inheritance
A parent class called SoftDrink has a brew() method. RootBeer and Beer classes inherit from SoftDrink. Each uses the brew() method but in different ways. Which aspect of object-oriented design is this?
polymorphism
You are designing a program for payroll. The Tax class has a method to calculate tax rates based on pay. You want to keep this method and its variables invisible to other classes. They can access the method but don’t get to see its details. This is an example of _____.
Encapsulation
You are designing a program for vehicles. Some of the class names include Semi, Compact, and SUV. If we create a new semi, it is said that the semi is a(n) _____ of a(n) _____.
instance ; Semi class
You have designed a hierarchy of classes for accounting software. All parent/child class relationships are set. What will you need for the classes to actually perform tasks?
Methods
An ________ is a component of a program that knows how to perform certain actions and how to interact with other elements of the program.
object
____________________ is an approach to problem solving where all computations are carried out using objects.
OOP
A ______ is a blueprint of an object. You need to have a ________ before you can create an object. Objects have ________ and ___________.
class, class, methods, attributes
A _________ is a procedure associated with a class and defines the behavior of the objects that are created from the class.
method
A ____________ is a combination of instructions that are combined to achieve some result.
function
An object is ____________ when the class is invoked.
instantiated
the _____________, creates the new instance.
constructor
_____ means that classes can share the properties and methods from other classes
inheritance
create/instantiate a new instance of the Customer class?
Customer name = new Customer();
The line of code that creates an object from the class is called a _____
constructor
Information can be _____ in a Java class, meaning available only to that class
Encapsulated
An object is a(n) _____ of a class
instance
A Java _______ is a representation of an entity and an implementation of its behaviors.
object
________ is determined by a group of data values associated with the object (such as make, model, color, number of doors, horsepower, passenger capacity, etc.).
State
____________ is a series of methods that implement the object’s functionality (such as start, accelerate, decelerate, turn, etc.).
Behavior
___________ is a unique ID used to identify the specific object from all other objects of the same kind (analogous to a real car’s VIN number). This ID is used internally by the Java system to reference and track an object and is not directly changeable by the programmer or user.
Identity
A _________ is a description of a group of objects that have common properties and behavior
class
The _______ operator is used to create specific objects from a given class description.
new
A _____ must be specified before a specific instance of a Java object can be created.
class declaration
After constructing a specific object, the Java new operator returns _____.
a reference to the object
A _____ is a description of a group of objects that have common properties and behavior. It’s a blueprint from which specific objects are created.
class
Actions are performed on an object by calling its _____.
methods
A specific instance of a class is created using the _____ operator.
new
the fancy term for creating a new instance of that class is _______________.
instantiation
_____________, inherit traits and properties from other objects
inheritance
The __________ tells the system to go out and grab some memory for the object and initialize variables.
constructor
________ constructors can be used by other methods in the same program or other programs. _______________ constructors are only used within the same program. ___________ constructors cannot be used outside of the current class.
Public, protected, private
What happens if you don’t create a constructor for a class?
Java creates a default constructor
Even though you won’t see it in your source code, the default constructor is there, with empty brackets. E.g., if you had a class called Fonts, a constructor exists: Fonts () { }
Code for how new objects are created:
Employee emp = new Employee();
The same variable names can be used in the class and constructor. In the constructor, how do you differentiate them?
Use the this keyword
If you have a variable for payRate in the class and as an argument to the constructor, refer to payRate in the constructor as this.payRate
If you call an overloaded method that doesn’t exist, what will happen
The program will not compile
You can have overloaded methods of the same name and number of parameters, if only the _____ are different.
Data types
When you _____________ a method, you’re actually creating another method with the same name. Each of the new methods has different ____________.
overload, parameters
When we alter a parent class’s method inside a child class, that is called _______________.
overriding
When a class inherits from more than one class, this is known as ________________.
multiple inheritance
Java does not allow ____________________. In order to implement similar functionality, you can use Java interfaces. These are like classes but only have _______ and______________.
multiple inheritance, fields, methods
When using multiple interfaces to mimic multiple inheritance, what keyword is added before the method declaration?
override
From a technical perspective, why is multiple inheritance difficult in Java?
Java loads classes dynamically. You can’t know which method(s) are valid.
The _____ problem describes the complexity of multiple inheritance in Java.
diamond
Which of the following code snippets illustrates a method of multiple inheritance in Java?
public class Z implements A, B { }
In order to inherit from the parent, use the keyword ____________ in the code.
extends
Polymorphism means _________
many forms
Polymorphism supports _____, which is several methods with the same name but different arguments.
overloading