Google Interview Question

What's the difference between abstract and interface in Java

Interview Answers

Anonymous

Dec 5, 2010

An abstract class may have some functions already defined where as an interface will not have any function defined. The extending(implements) class must define every function declared in the interface. With Abstract class, the extending class may override some of the functions defined in the abstract class.

Anonymous

Dec 14, 2010

Corrections to previous poster: 1. The extending class must define every function declared in te interface unless it is an abstract class 2. The extending class can extend multiple interfaces but only one class, abstract or not.

Anonymous

Feb 8, 2011

The interviewer does not require you to give syntax related answers, instead: 1- In general, the interfaces are favoured over calsses. 2- However, we use abstract classes in cases we want to enforce some implementations in subclasess