Pergunta de entrevista da empresa Crunchtime

What is the difference between abstract class and interface? when do you need to use abstract and when do you need to use interface in java?

Resposta da entrevista

Sigiloso

12 de set. de 2009

As Java allows multiple interface inheritance, decress coupling by prompting interface. Interface only has method declaration, no implemenation. Abstract class has method declaration and also some default implementation. Abstract class always used in an application package, with default method implementation to prompt code reuse. Interface is used to prompot encapsulation, so we can hide detail implementation from client.