JavaIntermediate#oop#interface

What is the difference between abstract class and interface?

Abstract class can have both abstract and concrete methods, instance variables, and constructors; a class can extend only one. Interface (Java 8+) can have default and static methods but no constructors; a class can implement multiple interfaces. Use interface for capability contracts, abstract class for shared base behavior.

Example
interface Flyable { void fly(); default void land(){ System.out.println("landing"); } }
abstract class Vehicle { abstract void move(); Vehicle(){ /* constructor allowed */ } }
class Plane extends Vehicle implements Flyable { void move(){} public void fly(){} }

Related Questions

1
JavaBeginner#oop#polymorphism

What is method overloading vs overriding?

Open
2
JavaBeginner#keywords

What is the final keyword?

Open
3
JavaIntermediate#memory#jvm

Explain Java memory model: heap vs stack.

Open