Which two forms of abstraction can a programmer use in Java?
A.
enums
B.
interfaces
C.
primitives
D.
abstract classes
E.
concrete classes
F.
primitive wrappers
Explanation:
When To Use Interfaces
An interface allows somebody to start from scratch to implement your interface or implement your
interface insome other code whose original or primary purpose was quite different from your
interface. To them, yourinterface is only incidental, something that have to add on to thetheir code
to be able to use your package. Thedisadvantage is every method in the interface must be public.
You might not want to expose everything.
*When To Use Abstract classes
An abstract class, in contrast, provides more structure. It usually defines some default
implementations andprovides some tools useful for a full implementation. The catch is, code using
it must use your class as thebase. That may be highly inconvenient if the other programmers
wanting to use your package have alreadydeveloped their own class hierarchy independently. In
Java, a class can inherit from only one base class.*When to Use Both
You can offer the best of both worlds, an interface and an abstract class. Implementors can ignore
yourabstract class if they choose. The only drawback of doing that is calling methods via their
interface name isslightly slower than calling them via their abstract class name.
Reference:http://mindprod.com/jgloss/interfacevsabstract.html
B
D