Packt Flashcards

1
Q

What is an object ?

OOP concepts

A
  • A core concept of OOP
  • An instantiation of a CLASS
  • Representation of a Real-World Object
  • Properties - Identity, State, Behaviour
  • Occupies space in memory
  • Has a lifecyle
  • Can communicate with other objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Class ?

OOP concepts

A
  • A core concept of OOP
  • A blueprint for an Object - which can usually be instantiated multiple times
  • Does not occupy space in memory
  • Defines member fields and methods
  • Can be of type Inner, Anonymous, Parent, Sub
  • Should follow Single Responsibility principle
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an abstraction ?

OOP concepts

A
  • Abstraction is a key OOP concept
  • Abstraction is representation of the key features of something without details of underlying concrete implementation
  • Abstraction is achieved through Interfaces and Abstract Classes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is encapsulation ?

OOP concepts

A
  • Encapsulation is a key OOP concept
  • It refers to restricting access to an object’s internal workings and state
  • limiting to public exposure points
  • Implemented by getters/setters and access modifiers
  • Advantages - loosely coupled code, easier to test, secure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Inheritance ?

OOP concepts

A
  • Inheritance is a core concept of OOP
  • Classes can be related
  • It is possible to Inherit the fields of a parent class by using the keword extend
  • Can only inherit from a single parent
  • It is advantageous because it allows for code resuse
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Polymorphism ?

OOP concepts

A
  • Polymorphism is a core concept of OOP
  • Polymorphism means many forms
  • There a two types of Polymorphism - runtime & compile time
  • Runtime Polymorphism is implementing method overriding in a sub-class
  • Compile Polymorphism is implementing method overloading
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is association ?

OOP concepts

A
  • Association is a core OOP concept
  • Association refers to the relationship between two classes that are independent of each other e.g. Person & Address
  • can be uni/bi directional, one-one, one-many, many-many
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is aggregation ?

OOP concepts

A
  • Aggregation is a key OOP concept
  • It is a uni-directional relationship
  • it is a “has-a” relationship as in Tennis Player “has-a” Raquet (but not the other way around
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is composition ?

OOP concepts

A
  • Composition is a core OOP concept
  • It is a more restrictive form of aggregation
  • It is a “has-a” relationship as in Car “has-a” Engine
  • more restrictive because If Car is destoyed the Engine is destroyed also
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is S in SOLID ?

OOP concepts

A
  • S - Single Responsibility
  • A CLASS should have only one responsibility
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is O in SOLID ?

OOP concepts

A
  • O - Stands for Open for Extension, Closed for modification
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is L in SOLID ?

OOP concepts

A
  • L - Stands for Liskov principle
  • Derived types must be completely substitutable for base types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the I in SOLID ?

OOP concepts

A
  • Interface Segregation principle
  • Clients should not be forced to implement unnecessary methods
  • If necessary an Interface should be split into smaller Interfaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly