OOP Flashcards
Polymorphism
Having multiple forms. An object could have multiple forms. Compile time polymorphism is method overloading. Runtime version is done via inheritance and interfaces.
Method overloading and method overriding
Overloading: create a method of the same name, but different return values
Overriding: Create your own implementation of an existing method
Can you override a private or static method in Java
No.
Features of OOP
Encapsulation, Polymorphism, Ineheritance Abstraction Composition Association Aggregation
Explain Encapsulation
Restricting data access of variables in an object. Restricting methods to an object
Explain abstraction
Concept of oops to construct an object related to the real world. Only general states and behaviors are defined. More specifics are left to be defined by the implementers
What is a class
Template of an object
What is an object
An instance of a classin
Static binding
Also called early binding. Resolving an association at compile time. Example method overloading
Dynamic binding
Also called late/virtual binding. Resolving an association at run time.
Override vs Overload
Override: same function name different signature. This is done by creating a method of the same name. But different parameters. This is compile time polymorphism.
Overload: same function name AND signature. Usually used when you want to extend/reuse functionality. This is known as run time polymorphism.