Computer Science Final Flashcards
What are the four pillars of OOP?
1) Abstraction
2) Encapsulation
3) Inheritance
4) Polymorphism
Define Abstraction
The process of identifying relevant classes, including their data members/values and methods, to solve a problem.
Define Encapsulation
Effective information hiding
Define Inheritance
Organization of relevant classes into a hierarchy of super-classes and sub-classes such that the sub-classes can inherit the data members and methods of the super class.
Define Polymorphism
Execution of different implementations of the exact same method call.
What are the benefits of polymorphism?
Smooth and easy extension and modification of a program
What are the benefits of inheritance?
- Code Reuse
- Code Maintenance
- Extensibility
- Polymorphism
Can an abstract class be instantiated?
No
Does a sub-class have to implement the abstract methods of the parent class?
Yes
Does a sub-class have to implement all of the methods in an abstract class?
No
Create an abstract method called “mystery” that returns a String and can only be used by a sub-class.
protected abstract String mystery( );
What are the benefits of an abstract class?
An abstract class is a prototype class that allows the programmer control the base functionality a sub-class must have.
What are the benefits of an abstract method?
They allow the programmer to ensure that every sub-class will implement that method.
How is an interface different than an abstract class?
An interface only has constants and abstract methods
What are the access levels if the “private” specifier is used?
Class
What are the access levels if no specifier is used?
Class and Package
What are the access levels if the “protected” specifier is used?
Class, Package, and Subclass
What are the access levels if the “public” specifier is used?
Class, Package, Subclass, World
What is the difference between overloading and overriding a method?
Overloading a method is when different instances of a method expect different parameters.
Overriding a method is when a subclass has the same method name as the parent class, but with a different implementation.
When should we use an abstract class as opposed to one that is instantiable?
An abstract class should be used if the sub-classes cover all possible forms of the superclass
Is the constructor method of a super-class inherited by its subclass?
No
What are the four components of recursion?
1) Stopping Condition
2) End Case
3) Recursive Step
4) Integration Step
What is a class?
A class is a template for how objects are created/deployed
What does a class have?
A class has both characteristics (data members) and behavior (methods).
