OOPS Module 1 - Exam Revision Guide
Q1. Cricket Player Statistics Tracker
(a) Create base class CricketPlayer with name, age, country.
- Subclass Batsman: runs, balls, centuries, fifties, strikeRate().
- Subclass Bowler: wickets, balls, runsConceded, economy(), bowlingAvg().
(b) Key formulas:
- Batting Avg = Runs / Outs
- Strike Rate = (Runs / Balls) * 100
- Bowling Avg = Runs Conceded / Wickets
- Economy = (Runs Conceded * 6) / Balls
(c) User system with inheritance:
- Base User (username, password, role)
- Customer can update profile
- Admin can manage users
- Use Hashing + Role-based Access Control (RBAC)
Q2. User System with Hashing + RBAC
(a) Base User class: username, email, passwordHash, methods for login & update.
(b) Customer subclass: name, address, contact, updateProfile().
Admin subclass: can create/delete/update users.
(c) Security:
- Store passwords using SHA-256 hashing.
- Role-based Access Control (RBAC).
Q3. Text Processing & Analysis
(a) Count characters (length), words (split), word frequency (HashMap).
(b) Longest word, Palindrome check, Most frequent char.
(c) Title case, Remove punctuation, Caesar cipher (shift text).
Q4. Theater Ticket Reservation (Exception Handling)
(a) Reserve seats, handle exceptions: Show not found, Invalid seat, Already booked.
(b) Payment exception if amount <= 0, Cancel booking exception if not found.
(c) Log errors with timestamp, validate inputs, always use try-catch.
Q5. Shapes & Calculator
(a) Abstract class Shape → Rectangle & Circle override calculateArea().
(b) Polymorphism: Shape ref → subclass object (dynamic dispatch).
(c) [Link]() handles division by zero using try-catch.
Q6. Array Problems
(a) Two-Sum using HashMap (O(n)).
(b) XOR trick to find single element, Add without + using bitwise ops.
(c) Method overloading: max/min/avg for int[] and double[].
Q7. Employee File Handling
(a) Use BufferedReader to read file line by line.
(b) Tokenize using StringTokenizer, store in Employee objects, add to List.
(c) Print in tabular format, allow future filtering/sorting.
Q8. Factorial + Bytecode
(a) Recursive factorial → bytecode shows recursive call (invokeStatic).
(b) Iterative factorial → uses loop, no recursion, less stack.
(c) Subclass overriding → bytecode shows dynamic dispatch (invokevirtual).
Q9. Abstraction + Polymorphism + Packages
(a) Abstract Animal class → Mammal, Bird, Reptile override eat/move/sound.
(b) Polymorphism: Animal ref → subclass object, runtime dispatch.
(c) Packages: customers, products, orders (modular design).
Q10. Library System (Media + Overloading + Packages)
(a) Media hierarchy: Book, CD, DVD inherit from Media.
(b) Method overloading in Library: add/update/delete for each media type.
(c) Use packages: [Link], [Link], [Link].