1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Object-Oriented Programming in Java

Connected

Exercise

Creating private properties

Class properties are often made private to restrict external access. For instance, in a Passport class, certain fields should be set only under specific conditions. You will make a car’s registration number private in the Car class to hide it.

Instructions

100 XP
  • Create a new private property called vehicleNumber that is an int type.