Ana içeriğe geç

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).

Egzersiz#java.boss.e1
Denemeler: 0Yükleniyor…

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).

Düzenleyici yükleniyor…
İpucu göster

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

3 denemeden sonra çözüm mevcut

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).

Egzersiz#java.boss.e2
Denemeler: 0Yükleniyor…

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.

Düzenleyici yükleniyor…
İpucu göster

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

3 denemeden sonra çözüm mevcut

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).

Egzersiz#java.boss.e3
Denemeler: 0Yükleniyor…

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).

Düzenleyici yükleniyor…
İpucu göster

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().

3 denemeden sonra çözüm mevcut

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.