Programming in Java

Unit 9: Abstract Class & Interface

From abstract blueprints to interface contracts — master Java's most powerful abstraction tools, design clean hierarchies, and write code that scales like enterprise software.

⏱️ 6 hrs theory + 4 hrs lab  |  💰 Earning Potential: ₹10K–₹30K/month  |  📝 30 MCQs (Bloom's Mapped)

💼 Jobs this unlocks: Java Backend Developer (₹5–10 LPA)  |  API Designer (₹8–15 LPA)  |  Software Architect (₹15–35 LPA)

Section A

Opening Hook — Every Aadhaar Verification Is a Java Interface in Action

🏢 Aadhaar API = Interface — Biometric Verification at Scale

India's Aadhaar system authenticates 1.4 billion identities. But here's the thing — UIDAI doesn't do all verifications itself. Banks like SBI, telecom companies like Jio, and payment apps like Paytm all verify Aadhaar. How? Through the Aadhaar Authentication API — essentially a Java-style interface.

The Aadhaar API defines a contract: any implementing agency MUST provide biometricVerify() and demographicAuth(). It doesn't care HOW each agency implements it internally — SBI uses fingerprint scanners at branches, Jio uses iris scanners at stores, Paytm uses face recognition on phones. The interface guarantees they all follow the same contract.

This is exactly what a Java interface does. It defines WHAT must be done, not HOW. Every bank, every telecom, every fintech — they all implements AadhaarAuth and provide their own implementation. If they miss even one method? Compilation error. Contract violated.

And what about the abstract class? Think of it as a partially-built template. UIDAI might provide a base abstract class AuthProvider with common logging and encryption already implemented, but leave biometricVerify() abstract — forcing each agency to provide their own biometric logic.

🇮🇳 UIDAI (Aadhaar)🇮🇳 SBI🇮🇳 Jio🇮🇳 Paytm🇮🇳 PhonePe🇮🇳 HDFC Bank
Every UPI transaction you make goes through at least 3 interface-based contracts — the payment gateway interface, the bank authentication interface, and the settlement interface. India processes over 10 billion UPI transactions per month, and each one relies on interface-driven architecture. The entire NPCI (National Payments Corporation of India) infrastructure is built on contract-first design — the exact pattern you'll master in this unit.
Section B

Learning Outcomes — 12 Bloom's Taxonomy Mapped

Bloom's LevelLearning Outcome
🔵 RememberDefine abstract class, abstract method, and interface; list the rules for each
🔵 RememberState the difference between abstract and interface keywords and list Java 8/9 additions to interfaces
🟢 UnderstandExplain why Java does not allow instantiation of abstract classes and why interfaces enable multiple inheritance
🟢 UnderstandDescribe functional interfaces, marker interfaces, and the interface segregation principle with Indian industry examples
🟡 ApplyWrite a Shape abstract class hierarchy with area() and perimeter() methods for Circle and Rectangle
🟡 ApplyImplement a Payable interface with Employee and Freelancer classes and compute payment amounts
🟠 AnalyzeCompare abstract class vs interface across 10+ parameters and decide which to use in a given design scenario
🟠 AnalyzeTrace the execution of code involving multiple interface implementation and method resolution
🔴 EvaluateCritique a class design that uses inheritance where interface composition would be better, proposing refactoring
🔴 EvaluateAssess when the Strategy Pattern using interfaces is preferable to template method using abstract classes
🟣 CreateDesign and code a complete Payable system with abstract base, interface contracts, and polymorphic processing
🟣 CreateBuild a sorting system using Comparable and Comparator interfaces for custom object ordering