<aside>
📋
L3.3 — Abstract Classes & Interfaces introduces abstract classes (classes that exist only to be inherited, cannot be instantiated), abstract methods (must be implemented by subclasses or the subclass must also be abstract), the final keyword (preventing subclassing, overriding, or value changes), global constants (public static final), and interfaces (100% abstract contracts that a class can implements — solving the multiple-inheritance limitation).
</aside>
📋 At a Glance
- [ ] Explain why abstract classes are needed (Broker redesign problem)
- [ ] Know that abstract classes cannot be instantiated with
new
- [ ] Know that abstract methods have no body — declared with semicolon, not curly brackets
- [ ] If a class has at least one abstract method, the class must be declared abstract
- [ ] An abstract class does not have to contain abstract methods
- [ ] Abstract methods cannot be
private — must be protected or public
- [ ] Subclasses must implement all inherited abstract methods, or be declared abstract themselves
- [ ] Use
final on classes, methods, and variables to prevent changes
- [ ] Know that
public static final variables are called global constants (ALL_CAPS naming)
- [ ] Explain why Java forbids multiple inheritance (diamond problem)
- [ ] Declare and implement interfaces using the
implements keyword
- [ ] Know that interfaces can only contain abstract methods and global constants
- [ ] A class can extend one class but implement many interfaces
- [ ] An interface can extend multiple other interfaces
- [ ] Use an interface as a parameter type to accept any implementing class
1. Why Abstract Classes?