Object-oriented design
The four ideas
Encapsulation, abstraction, inheritance and polymorphism, in one line each and with their differences.
In two minutes
One idea to a line
Encapsulation bundles data with the methods that use it and hides the data behind access control, so an object guards its own rules.
Abstraction shows what an object does and hides how: callers use an interface and not the details.
Inheritance lets a class reuse and extend another (an "is-a" relation). Polymorphism lets one call behave differently depending on the real object.
Compile-time polymorphism is overloading (same name, different parameters). Run-time polymorphism is overriding resolved through the real type of the object.
Prefer composition ("has-a") when the relation is not truly "is-a": it is more flexible and avoids deep hierarchies.
Slips people make here
Interviewers know them too
Confusing abstraction (what is shown) with encapsulation (what is protected).
Calling overloading "run-time polymorphism".
Using inheritance just to reuse code.
Your practice here
Not started
12 written questions
No answers yet