SOFTWARE ENGINEERING

SOFTWARE DESIGN

DESIGN PATTERNS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
“Program to an interface, not an implementation.” means:
A
Do not program to an abstract superclass.
B
Program to a supertype.
C
If possible, put everything in one class.
D
Go for a concrete implementation whenever possible.Show answersExplanationPreviousNext
Explanation: 

Detailed explanation-1: -It means that you should try to write your code so it uses an abstraction (abstract class or interface) instead of the implementation directly. Normally the implementation is injected into your code through the constructor or a method call.

Detailed explanation-2: -If you only want to inherit method signatures (name, arguments, return type) in the subclasses, use an interface, but if you also want to inherit implementation code, use a superclass.

Detailed explanation-3: -Yes, it is mandatory to implement all the methods in a class that implements an interface until and unless that class is declared as an abstract class.

There is 1 question to complete.