Kyūkei Master Hub
SCS2108 | Phase Study Card
👁️ -- opens | 0%

Phase 4: Interfaces, Abstract Classes & Dynamic Binding

This is one of the most frequently asked written exam questions in SCS2108. Master the architectural comparison and dynamic method dispatch.

1. Abstract Class vs Interface (Definitive Comparison)

Feature Abstract Class Interface
Relationship Represents an IS-A identity (hierarchical base). Represents a CAN-DO capability (contract).
Multiple Inheritance Single inheritance only (a class can extend only 1 abstract class). Multiple inheritance (a class can implement multiple interfaces).
State / Fields Can have instance fields with state (`int balance`, `String name`). Only `public static final` constants (no instance state).
Constructors Has constructors (invoked via `super()`). No constructors (cannot be instantiated).
Methods Can have both abstract methods and concrete methods with code. Abstract by default (Java 8+ allows `default` & `static` methods).
💡 Examiner Distinction Tip
When asked when to use which: Use an Abstract Class when sharing code and instance state among closely related classes. Use an Interface to define a common role/contract across unrelated classes (e.g., `Printable`, `Serializable`).

2. Dynamic Binding & Virtual Method Dispatch

Binding refers to connecting a method call to its method body.

Static Binding (Early Binding):

Dynamic Binding (Late Binding):

// Polymorphic Declaration: Shape s = new Circle(); // Compile Time: Compiler checks if Shape has draw() method. // Runtime: JVM uses object's vtable (Virtual Method Table) to call Circle's draw()! s.draw();

⚡ Quick Self-Test

Q: Can a Java class extend an abstract class AND implement 3 interfaces simultaneously?

Answer: Yes!.
Syntax: public class MyClass extends MyAbstractClass implements InterfaceA, InterfaceB, InterfaceC. Java permits single class inheritance alongside multiple interface implementations.