0% found this document useful (0 votes)
10 views4 pages

Advanced Java Exam Questions

The document outlines five advanced Java exam questions focused on designing systems using object-oriented principles such as abstraction, inheritance, and interfaces. Each question includes specifications for classes, interfaces, input/output formats, and test cases for various scenarios like transportation management, academic result processing, banking systems, media libraries, and e-commerce marketplaces. The expected outputs for the provided test cases are also included to illustrate the functionality of the designed systems.

Uploaded by

sgdarkfake.0204
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Advanced Java Exam Questions

The document outlines five advanced Java exam questions focused on designing systems using object-oriented principles such as abstraction, inheritance, and interfaces. Each question includes specifications for classes, interfaces, input/output formats, and test cases for various scenarios like transportation management, academic result processing, banking systems, media libraries, and e-commerce marketplaces. The expected outputs for the provided test cases are also included to illustrate the functionality of the designed systems.

Uploaded by

sgdarkfake.0204
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Advanced Java Exam Questions for JAVA FAT Q1

Q1. Smart City Transportation Management System


Design an extensible system to manage different TransportModes in a city.

1. Create an abstract class `Transport` with attributes: `vehicleId`, `baseFare`, and abstract method
`calculateFare(distance)`.
2. Create interface `EcoFriendly` with method `getCarbonFootprint()`.
3. Subclasses:
- `Bus`: fare = baseFare + 5 × distance
- `Taxi`: fare = baseFare + 10 × distance
- `ElectricTaxi`: inherits `Taxi`, implements `EcoFriendly` (carbon footprint = 0.2 × distance)
4. Input format:
<type> <vehicleId> <baseFare> <distance>
5. Output format:
Vehicle <vehicleId>: Fare=<fare> Carbon=<carbon_footprint_if_applicable>

Test Cases:
[Link]
Bus B102 15 10
Taxi T202 25 8
ElectricTaxi E303 20 12

Expected Output:
Vehicle B102: Fare=65.0
Vehicle T202: Fare=105.0
Vehicle E303: Fare=140.0 Carbon=2.4

ElectricTaxi ET01 30 20
Bus B201 10 15

Taxi TX01 50 5
ElectricTaxi E100 25 10

Q2. Academic Institution Result Processor


Build a full academic model using abstraction and inheritance.

1. `abstract class Person` → name, id.


2. `interface Evaluatable` → `calculateGrade()`.
3. `class Student` extends `Person`, implements `Evaluatable`.
- Has `marks[]` of 5 subjects.
- Grade rules: average ≥90 → “A+”, 80–89 → “A”, 70–79 → “B”, else “C”.
4. `class Professor` extends `Person`, implements `Evaluatable`.
- Has `researchPapers` count.
- Grade: ≥10 → “Outstanding”, 5–9 → “Excellent”, else “Good”.
5. Input format:
<role> <id> <name> <data...>
6. Output format:
<role> <name>: Grade - <grade>

Test Cases:
[Link]
Student 101 Riya 95 92 88 90 85
Professor 201 Mehta 12
Student 102 Aarav 70 75 68 80 72

Expected Output:
Student Riya: Grade - A+
Professor Mehta: Grade - Outstanding
Student Aarav: Grade - B

Q3. Multi-Level Banking System with Abstract Policy Enforcement


Design a system for multiple account types with enforced transaction rules.

1. `abstract class Account` → `accountNumber`, `balance`.


2. `interface Transaction` → `deposit(amount)`, `withdraw(amount)`.
3. `SavingsAccount`, `CurrentAccount` inherit `Account` and implement `Transaction`.
4. `abstract class PremiumAccount` extends `Account`, adds `rewardPoints` and abstract
`calculateReward()`.
5. `class PlatinumAccount` inherits `PremiumAccount` → 1 point per ₹1000 deposited.
6. Input format:
<type> <accountNumber> <initialBalance> <transactionType> <amount>
7. Output format:
<type> <accountNumber>: Balance=<value> Reward=<points_if_any>

Test Cases:
[Link]
Savings 101 10000 deposit 5000
Current 202 20000 withdraw 5000
Platinum 303 15000 deposit 10000

Expected Output:
Savings 101: Balance=15000.0
Current 202: Balance=15000.0
Platinum 303: Balance=25000.0 Reward=10

Q4. Media Library Polymorphic Engine


Model a digital media library using both abstract classes and interfaces.

1. `interface Playable` → `play()`.


2. `abstract class MediaItem` → `title`, `duration`, and abstract `displayInfo()`.
3. `class Song` and `class Movie` extend `MediaItem` and implement `Playable`.
4. `class Podcast` inherits `MediaItem`, implements `Playable` with extra `episodes`.
5. Input format:
<type> <title> <duration> [episodes_if_podcast]
6. Output format:
Playing <type>: <title> (<duration> mins)

Test Cases:
[Link]
Song ShapeOfYou 4
Movie Inception 148
Podcast TechTalk 60 12

Expected Output:
Playing Song: ShapeOfYou (4 mins)
Playing Movie: Inception (148 mins)
Playing Podcast: TechTalk (60 mins)

Q5. E-Commerce Marketplace Engine


Design a system that models vendors, products, and dynamic discounts.

1. `interface Discountable` → `double applyDiscount(double price)`.


2. `abstract class Product` → `productId`, `name`, `price`, abstract `getFinalPrice()`.
3. Subclasses:
- `Electronics` (implements `Discountable`): 10% off
- `Clothing` (implements `Discountable`): 20% off
- `Grocery` (no discount)
4. `Vendor` class holds a list of `Product`s and a method `showAllProducts()`.
5. Input format:
<vendorName>
<productType> <id> <name> <price>
...
END
6. Output format:
Vendor <name>:
<productName> -> FinalPrice=<value>

Test Cases:
[Link]
Amazon
Electronics E01 Laptop 60000
Clothing C01 Jacket 3000
Grocery G01 Milk 50
END

Expected Output:
Vendor Amazon:
Laptop -> FinalPrice=54000.0
Jacket -> FinalPrice=2400.0
Milk -> FinalPrice=50.0

You might also like