3 Describing objects and classes
| Exam objectives covered in this chapter |
What you need to know |
| [6.2] Define the structure of a Java class |
Structure of a Java class, with its components: package and import statements, class declarations, comments, variables, and methods. Difference between the components of a Java class and that of a Java source code file. |
| [6.1] Declare and instantiate Java objects, and explain objects' lifecycles (including creation, dereferencing by reassignment, and garbage collection) |
Understanding the differences between variable declaration and initialization, instance creation and its accessibility. Garbage collection in Java. Determining when instances are eligible to be garbage collected. |
| [6.3] Read or write to object fields. |
Object fields can be read from and written to by directly accessing instance variables and calling methods. The correct notation to call methods on an object. Methods may or may not change the value of instance variables. Access modifiers affect access to instance variables and methods that can be called using a reference variable. Nonstatic methods can’t be called on uninitialized objects. |
Creating class and their instances is one of the basics to program in Java and the OCP Java SE 11 Programmer I exam ensures that you know it well. In the exam, you’ll be asked questions on the structure of a Java class, object’s life cycle, and accessing object fields. Given that information, this chapter will cover the following: