Pregunta de entrevista de IBM

Explain the difference between a Java interface and a Java abstract class.

Respuestas de entrevistas

Anónimo

27 de jul de 2011

An abstract class is a generic that usually has some common methods defined that subclasses can use. However, the class itself contains one or more abstract methods that the child classes should implement. Abstract classes cannot be used directly,they must be instantiated by a subclass. Inferfacesare a template for method defition and can be adopted by any class to define a particular behavior. One key difference is that's lass can only extend one other class but it can implement many interfaces.

2

Anónimo

5 de ago de 2011

in addition to what the Interview Candidate wrote: abstract class can contain concrete methods while interfaces can only have methods with no body.

1