Difference between Abstract Class and Interface in Java
This is a favourite interview question, so learn it like a class, not like a slogan. Abstract class = a partial parent in a family. Interface = a can-do contract. Shape is a family: circle and rectangle are shapes. Drawable is a capability: something that can draw. A Circle is a Shape, and it can also be Drawable. That one picture is enough if you can explain it slowly.
You cannot do new Shape() if Shape is abstract. You cannot do new Drawable() on a plain interface. A class extends only one abstract parent. A class can implement many interfaces. Say that first: one parent class, many interfaces. Interviewers wait for that line. Then they ask why.
Why? Abstract class can keep real fields and real methods — colour, x, y, a helper print() that every child reuses. Interface is mainly “you must be able to do this”: draw(), compareTo(). Modern Java has default methods on interfaces, yes. Still don’t say they are the same. Intent is different: family shared code vs capability contract.
Let’s take this on the board. abstract class Animal { abstract void sound(); } interface Pet { void play(); } class Dog extends Animal implements Pet { void sound() { print Bark; } public void play() { print Fetch; } }. Then Dog d = new Dog(); d.sound(); d.play();. Output: Bark then Fetch. Dog is an Animal (IS-A family) and also a Pet (CAN-DO). One tiny program, both ideas.
How to choose in a project. Related types that share code → abstract class. Circle and Rectangle both need colour and area() — Shape. Unrelated types that share an ability → interface. A printer and a screen both can implement Drawable. A car and a bird are not one family. Don’t force Flyable on a car.
Answer with a small table if they ask “difference”: inheritance count, shared code/fields, purpose (IS-A vs CAN-DO), keyword (extends vs implements). Then give Shape vs Drawable. Don’t recite ten Java version notes unless they ask about default methods.
Shape (abstract class)
colour, area(), print()
│ extends
▼
Circle
│ implements
▼
Drawable (interface)
draw()
abstract class = family + shared code
interface = can-do contractTable: one parent vs many interfaces; shared code vs contract; IS-A vs CAN-DO. Then one example: Shape vs Drawable.