Packages As you saw in the previous example, Java classes are grouped into packages. The import statement tells the compiler which package to look in to find a class. This is similar to how mailing a letter works. Imagine you are mailing a letter to 123 Main Street, Apartment 9. The mail carrier first brings […]
Passing Parameters to a Java Program Let’s see how to send data to our program’s main() method. First, we modify the Zoo program to print out the first two arguments passed in: public class Zoo { public static void main(String[] args) { System.out.println(args[0]); System.out.println(args[1]); } } The code args[0] accesses the first element of the […]
Writing a main() Method A Java program begins execution with its main() method. In this section, you learn how to create one, pass a parameter, and run a program. The main() method is often called an entry point into the program, because it is the starting point that the JVM looks for when it begins […]
Comments Another common part of the code is called a comment. Because comments aren’t executable code, you can place them in many places. Comments can make your code easier to read. While the exam creators are trying to make the code harder to read, they still use comments to call attention to line numbers. We […]
Downloading a JDK Every six months, Oracle releases a new version of Java. Java 17 came out in September 2021. This means that Java 17 will not be the latest version when you download the JDK to study for the exam. However, you should still use Java 17 to study with since this is a […]
OCP EXAM OBJECTIVES COVERED IN THIS CHAPTER: ✓✓ Handling date, time, text, numeric and boolean values ✓✓ Utilizing Java Object-Oriented Approach Welcome to the beginning of your journey to achieve a Java 17 certification. We assume this isn’t the first Java program-ming book you’ve read. Although we do talk about the basics, we do so […]