Fundamentals of Programming Flashcards
Define Instantiation
The process of an object being created from a class template.
What is encapsulation?
The bundling of attributes and methods into a single object, typically called a class.
How does information hiding work?
Each object should only expose a high-level interface for using it. This interface should hide internal implementation details, only revealing operations necessary for other objects.
Explain how inheritance works?
Objects share common logic.
Parent class contains common logic.
Child classes contain unique logic.
The child class reuses all fields and methods as well as implementing its own.
Explain the concept of overriding.
Each child class implements its own version of a method it inherits.
Describe relationships for following: inheritance, aggregation, composition
Inheritance:
A cat “is a” animal
Association:
A student “has a” teacher
A teacher “has a” student
Composition:
A page is “part of” a book
In composition, if the container is destroyed, what happens to the contained class?
It cannot exist independently, it is also destroyed.
In aggregation, can a child and parent class exist independently.
Yes, if a car is destroyed the engine doesn’t need to be destroyed as well.
How is aggregation represented?
Open diamond towards the container.
How is composition represented?
Filled diamond towards the container.
How is inheritance represented?
Open arrowhead that points to the parent class.
What is the structured approach?
What are the advantages?
The process of taking a big problem and breaking it down into smaller problems.
Saves time, and reduces risks and bugs.
Compare public, private, and protected methods and attributes.
Public:
Accessible from any part of the program
Private:
Only accessible within the class
Protected:
Accessible within the class and its subclasses