Core Java 3: OOP OOD Flashcards

(7 cards)

1
Q

4 Pillars of OOP

A

A PIE: Abstraction, Polymorphism, Inheritance, and Encapsulation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Abstraction

A

hiding complex code from user; user is only concerned with inputs/outputs, don’t need to worry about internal components; abstraction creates reusable/discrete modules; write something once and use it anywhere to fulfill task in application; single task as a method; group of tasks as class; group of related classes as layer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Polymorphism

A
  • ability to give different definitions for performing a task (OVERLOADING & OVERRIDING).
  • Overloading: ability to give a definition for a method which takes different arguments; early-binding, compile-time, static binding.
  • Overriding: define child-specific implementation of parent method. Child method needs to perform same overall function (not overriding if child is violating intent of parent); late-binding, runtime, dynamic binding.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Inheritance

A
  • Ability to set parent-child relationships between classes
  • all attributes and behaviors of parent are accessible to child.
  • Code reuse: define attributes & methods in parent, any number of children can reuse definitions.
  • Extensibility: can use abstract parent as dependency to implement concrete child.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Encapsulation

A

maximizing cohesion by grouping related elements together; wrap cohesive elements together, protect access by making them private, limit access via getters/setters so you have precise control over how data stored/retrieved

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Cohesion

A

togetherness; extent to which elements of code belong together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Coupling

A

measurement of dependency between classes; if I change sth. in class A, does it break functionality in class B?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly