Skip to main content
eLearner.app

End of the Java Course

Summary and final challenge

Congratulations: you have made it through the 4 modules of the Java Course — from basic variables and loops to OOP encapsulation, inheritance, interfaces, and using ArrayList. Below is a map of everything you have mastered and a three-step final challenge.

Reminder: Java exercises are verified statically (keywords). To actually run the code, each exercise provides a OneCompiler button that copies the code and opens the sandbox.

01 · Basics

  • variables
  • primitive types
  • if / else
  • for/while loops

02 · OOP Basics

  • classes and objects
  • instance fields
  • constructors
  • overloading

03 · OOP Advanced

  • inheritance
  • extends
  • super()
  • polymorphism
  • abstract classes

04 · Interfaces and Collections

  • interface
  • implements
  • ArrayList
  • generics
  • for-each

The final challenge, in three steps

Combine what you have learned about Java by building three components: a method to calculate discounted prices, a class hierarchy for bank accounts, and a billing utility using interfaces and dynamic lists.

1 · Calculate discounted price

Write a static method that calculates the total price, applying a 10% discount if the purchased quantity is at least 10. Module 1 (variables and control flow).

Exercise#java.boss.e1
Attempts: 0Loading…

Define the method public static double getDiscountedPrice(double price, int quantity) that returns the total price. If quantity is 10 or more, apply a 10% discount (multiply by 0.9).

Loading editor…
Show hint

Use an if statement to check if the quantity is greater than or equal to 10 and multiply accordingly.

Solution available after 3 attempts

2 · Savings account with inheritance

Implement the SavingsAccount class extending Account, calling the parent constructor and adding a method to accumulate interest. Modules 2 & 3 (OOP).

Exercise#java.boss.e2
Attempts: 0Loading…

Write the SavingsAccount class extending Account. Define a constructor accepting balance and interestRate and call super(balance). Implement the method public void addInterest() that increases balance by adding balance * interestRate.

Loading editor…
Show hint

Use extends Account to inherit, super(balance) in the constructor to initialize the balance, and modify the protected balance field in addInterest().

Solution available after 3 attempts

3 · Billing with interfaces and ArrayList

Implement a Taxable interface and an Invoice class that stores product prices in an ArrayList to calculate the total tax. Module 4 (interfaces and collections).

Exercise#java.boss.e3
Attempts: 0Loading…

Complete the Invoice class which implements the Taxable interface. Add the addItem(double price) method to insert items into items, implement getTaxRate() to return 0.22 (22% tax), and getTaxAmount() to calculate the total tax (sum of items multiplied by the tax rate).

Loading editor…
Show hint

addItem should call items.add(price). getTaxAmount() should iterate through the list using a for-each loop, sum the elements, and multiply the sum by getTaxRate().

Solution available after 3 attempts

Printable Cheatsheet

A single page with all the essential syntax of modern Java, ready to keep handy while you code.

Open the cheatsheet

What now?

Consistent practice is the best way to strengthen your skills. Open the Java Playground to experiment freely with complex scenarios or to prepare your code snippets before testing them on OneCompiler.