CLASS NOTES PART 2 Flashcards
What are objects?
Instance of a class
What is a class?
Structure that contains data and methods
Four Basic OOP Principles
1.) Encapsulation
2.) Inheritance
3.) Polymorphism
4.) Abstraction
What is Encapsulation?
Protects the data inside of it
What is Inheritance?
One object can re-use the code of another object through an IS-A relationship vs a HAS-A relationship.
1.) Strong relationship
2.) Fragile base class – changes to the
parent can break the behavior of it’s
children.
3.) Class Explosion
What is Polymorphism?
Many shapes
Parameter overloading
add(int i1, i2){}
add(int i1, i2,int i3){}
Many objects with the same base class
can have different shapes
class Shape{ draw(){}}
class Circle extends Shape{ draw(){}}
class Square extends Shape{draw{}}
What is Abstraction?
Any method that does anything is providing functionality that I don’t need to know about.