Programming in Java

Unit 12: I/O Fundamentals & Generics

From byte streams to type-safe collections — master Java's I/O architecture, serialization, and generics to build robust, production-ready applications.

⏱️ 6 hrs theory + 5 hrs lab  |  💰 ₹5K–₹15K/month  |  📝 30 MCQs (Bloom's Mapped)

💼 Jobs this unlocks: Java Backend Developer (₹5–10 LPA)  |  Software Engineer (₹6–14 LPA)  |  File Automation Freelancer (₹5K–15K/mo)

Section A

Opening Hook — Every Aadhaar Record Travels Through Java I/O

🏢 How 1.4 Billion Aadhaar Records Move Securely Across India

When you walk into an Aadhaar enrolment centre in Lucknow, the operator captures your fingerprints, iris scan, photo, and demographics. That citizen object — a Java object containing your name, DOB, address, and biometric hashes — must travel from a local machine in UP to UIDAI's central servers in Bengaluru.

How? Java Serialization. The citizen object is serialized (converted to a byte stream) using ObjectOutputStream, encrypted, written to a file, transmitted over the network, and deserialized at the UIDAI server using ObjectInputStream. The biometric data is marked transient — it gets separate, more secure handling.

Every Aadhaar record — all 1.4 billion of them — has been read, written, serialized, and deserialized using Java I/O. Meanwhile, the APIs serving Aadhaar verification to banks and telecom companies use Generics to ensure type-safe data containers, so a Response<AadhaarData> can never accidentally hold a PANCard object.

What if YOU could build this? What if you could serialize any Java object to disk, read CSV files line-by-line at blazing speed, and build type-safe data structures that catch errors at compile time instead of runtime? That's exactly what this unit teaches you.

🇮🇳 UIDAI (Aadhaar)🇮🇳 Infosys🇮🇳 TCS🇮🇳 Razorpay🇮🇳 PhonePe🇮🇳 IRCTC
UIDAI's Aadhaar system is the world's largest biometric ID program. Built primarily in Java, it processes over 100 million authentication requests daily. The I/O layer alone handles petabytes of serialized data monthly. Java's stream-based I/O architecture was a key reason UIDAI chose it — reliable, cross-platform, and battle-tested.
Section B

Learning Outcomes — Bloom's Taxonomy Mapped (12 Outcomes)

Bloom's LevelLearning Outcome
🔵 RememberList the core classes in Java's byte stream and character stream hierarchies
🔵 RememberDefine serialization, deserialization, and the role of the transient keyword
🔵 UnderstandExplain how BufferedReader improves performance over raw FileReader using internal buffering
🔵 UnderstandDescribe why generics provide compile-time type safety and eliminate the need for explicit casting
🟢 ApplyWrite a Java program that reads a CSV file using BufferedReader and writes parsed output using BufferedWriter
🟢 ApplyImplement a generic class GenericStack<T> with push, pop, and peek operations
🟢 AnalyzeCompare Scanner vs BufferedReader for reading user input — performance, parsing, and use cases
🟢 AnalyzeDifferentiate between <? extends T> (upper bound) and <? super T> (lower bound) using the PECS rule
🟠 EvaluateAssess when to use byte streams vs character streams for different file types (binary vs text)
🟠 EvaluateJudge the trade-offs of making a field transient vs serializing sensitive data with encryption
🟠 CreateDesign a GenericPair<K,V> class and use it in a real-world key-value store scenario
🟠 CreateBuild a complete Student Record Serializer that writes/reads student objects to/from binary files