What's the difference between an interface and an abstract class?
Anonymous
Interface: - all methods are abstract by default. So one cannot declare variables or concrete methods in interfaces. - all methods declared in an interface must be public. - interfaces cannot contain variables and concrete methods except constants. - a class can implement many interfaces. Abstract Class: - For abstract class, a method must be declared as abstract. It cannot have an implementation. - Abstract methods can be declared with access modifiers like public, protected etc. When implementing these methods in a subclass, you must define them with same (or less restricted) visibility. - Abstract classes can contain variables and concrete methods. - Class can inherit only one abstract class. - Multiple inheritance is not possible for Abstract class.
Check out your Company Bowl for anonymous work chats.