1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Exceptions in Java

Connected

Exercise

Defining a POJO

Building a POJO is about creating a straightforward Java class following a few rules. POJO classes are simple and independent; they don't extend other classes or implement interfaces. The main task is to define the fields and create getter and setter methods to access them. Here, you create a POJO for transporting savings account data in a Java application.

Instructions

100 XP
  • Add a field balance of type double to hold the account balance value, making sure to choose the correct access.
  • Define a getter method to return the balance field value.
  • Define a setter method to allow the balance field to a new value.
  • In the setter method, set the balance field to the setter's argument.