Lecture 6 - OOP Concepts Flashcards
What concept encloses the data and functions that operate on that data into a single unit, the class?
Encapsulation
TF: Hiding private details from the outside world is an example of encapsulation
True
TF: Encapsulation allows external code to directly access class details without the use of predefined methods
False. They provide methods that allow users to access/modify it (i.e. no direct access)
What concept separates interface of a class from its implementation and focuses on the interface?
Abstraction
Hiding implementation details of a class and only presenting a clean and easy-to-use interface via class’ member function is an example of…
Abstraction
What does isolating the impact of changes made to the code mean regarding Abstraction?
Means changes to internal implementation doesn’t affect how users/programs interact with the interface (i.e. changing internal implementation doesn’t affect how users/programs interact with it)
What is meant by Black-box system in Abstraction?
System where internal workings or implementation details are hidden from the user (user can only interact with it through input, output)
What is Inheritance in programming?
Concept where classes can be organized into hierarchies allowing code reuse
What is polymorphism?
Ability of different classes (with same parent) to change the behaviour of the same method.
ex:
Parent class: Animal
Child classes: Dog, Cat
method in Animal, sound( ), changes bases on animal
TF: A static method can use a non-static member
False. Static methods belong to class itself while non-static member belongs to instance of that class
TF: Strongly typed languages means variables must be declared with a specific type and type conversions are explicit
True
What is Singleton pattern?
Design pattern where only one instantiation of a class is allowed
What are the three methods of implementing a Singleton pattern?
- Eager Initialization method
- Lazy Initialization method
- Thread Safe Signleton method
Which Singleton Pattern implementation method initializes the object at the time of class loading?
Eager Initialization method
What is the advantage of Eager Initialization implementation of Singleton pattern?
Very simple to implement