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)
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.
Learning Outcomes — Bloom's Taxonomy Mapped (12 Outcomes)
| Bloom's Level | Learning Outcome |
|---|---|
| 🔵 Remember | List the core classes in Java's byte stream and character stream hierarchies |
| 🔵 Remember | Define serialization, deserialization, and the role of the transient keyword |
| 🔵 Understand | Explain how BufferedReader improves performance over raw FileReader using internal buffering |
| 🔵 Understand | Describe why generics provide compile-time type safety and eliminate the need for explicit casting |
| 🟢 Apply | Write a Java program that reads a CSV file using BufferedReader and writes parsed output using BufferedWriter |
| 🟢 Apply | Implement a generic class GenericStack<T> with push, pop, and peek operations |
| 🟢 Analyze | Compare Scanner vs BufferedReader for reading user input — performance, parsing, and use cases |
| 🟢 Analyze | Differentiate between <? extends T> (upper bound) and <? super T> (lower bound) using the PECS rule |
| 🟠 Evaluate | Assess when to use byte streams vs character streams for different file types (binary vs text) |
| 🟠 Evaluate | Judge the trade-offs of making a field transient vs serializing sensitive data with encryption |
| 🟠 Create | Design a GenericPair<K,V> class and use it in a real-world key-value store scenario |
| 🟠 Create | Build a complete Student Record Serializer that writes/reads student objects to/from binary files |