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