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

Connected

Exercise

Using a POJO

Here, a POJO class Movie has already been defined for you. Your task is to create and use an instance of Movie to hold data for the thriller "Jaws" - thus giving you a chance to see and practice how setters and getters work to encapsulate POJO data.

Instructions

100 XP
  • Create an instance of Movie and assign it to a variable jaws.
  • Set the Movie objects title field to "Jaws".
  • Set the Movie objects director field to "Spielberg".
  • Print out the Movie objects rating.