1.

Using relevant properties highlight the differences between interfaces and abstract classes.

Answer»
  • Availability of methods: Only abstract methods are available in interfaces, whereas non-abstract methods can be present along with abstract methods in abstract classes.
  • Variable types: Static and final variables can only be declared in the case of interfaces, whereas abstract classes can ALSO have non-static and non-final variables.
  • Inheritance: MULTIPLE INHERITANCES are facilitated by interfaces, whereas abstract classes do not promote multiple inheritances.
  • Data MEMBER accessibility: By default, the class data members of interfaces are of the public- type. Conversely, the class members for an abstract class can be protected or private also.
  • Implementation: With the help of an abstract class, the implementation of an interface is easily possible. However, the converse is not true;

Abstract class example:

public abstract class Athlete {public abstract void walk();}

Interface example:

public interface Walkable {void walk();}


Discussion

No Comment Found