Choosing the Correct Answer(s)
Each exam consists entirely of multiple-choice questions. There are between four and seven possible answers. If a question has more than one answer, the question specifically states exactly how many correct answers there are. This book does not do that. We say Choose all that apply to make the questions harder. This means the questions in this book are generally harder than those on the exam. The idea is to give you more practice so you can spot the correct answer more easily on the real exam.
Reading the Exam Code
Many of the questions on each exam are code snippets rather than full classes. Saving space by not including imports and/or class definitions leaves room for lots of other code. You should only focus on import
statements when the question specifically asks about them.
For example, it is common to come across classes on the exam with import
statements and portions omitted, like so:
public class Zoo implements Serializable { String name; // Getters/Setters/Constructors omitted }
In this case, you can assume that java.io.Serializable
is imported and that methods like getName()
and setName()
, as well as related constructors, exist. For instance, we would expect this code to compile:
var name = new Zoo("Java Zoo").getName();
Encountering Out-of-Scope Material
When you take an exam, you may see some questions that appear to be out of scope. Don't panic! Often, these questions do not require knowing anything about the topic to answer the question. For example, after reading this book, you should be able to spot that the following does not compile, even if you've never heard of the java.util.logging.Logger
class.
final Logger myLogger = Logger.getAnonymousLogger(); myLogger = Logger.getLogger(String.class.getName());
The classes and methods used in this question are not in scope for the exam, but the reason it does not compile is. In particular, you should know that you cannot reassign a variable marked final
.
See? Not so scary, is it? Expect to see at least a few structures on the exam that you are not familiar with. If they aren't part of your exam preparation material, then you don't need to understand them to answer the question.
Reviewing Question Types
The following list of topics is meant to give you an idea of the types of questions and oddities that you might come across on the exam. Being aware of these categories of questions can help you get a higher score on an exam.
Questions with Extra Information Provided Imagine the question includes a statement that XMLParseException is a checked exception. It's fine if you don't know what an XMLParseException is or what XML is, for that matter. (If you are wondering, it is a format for data.) This question is a gift. You know the question is about exception handling.
Questions with Embedded Questions To answer some questions on the exam, you may have to answer two or three subquestions. For example, the question may contain two blank lines and ask you to choose the two answers that fill in each blank. In some cases, the two answer choices are not related, which means you're really answering multiple questions, not just one! These questions are among the most difficult and time-consuming on the exam because they contain multiple, often independent, questions to answer. Unfortunately, the exam does not give partial credit, so take care when answering questions like these.
Questions with Unfamiliar APIs If you see a class or method that wasn't covered in this book, assume that it works as you would expect. Some of these APIs you might come across, such as SecurityManager, were on the Java 11 exam and are not part of the Java 17 exams. Assume that the part of the code using that API is correct, and look very hard for other errors.
Questions with Made-Up or Incorrect Concepts In the context of a word problem, the exam may bring up a term or concept that does not make any sense, such as saying an interface inherits from a class, which is not a correct statement. In other cases, the exam may use a keyword that does not exist in Java, like struct. For these, you just have to read carefully and recognize when the exam is using invalid terminology.
Questions That Are Really Out of Scope When introducing new questions, Oracle includes them as unscored questions at first. This allows the exam creators to see how real exam takers do without impacting your score. You will still receive the number of questions the exam lists. However, a few of them may not count. These unscored questions may contain out-of-scope material or even errors. They will not be marked as unscored, so you still have to do your best to answer them. Follow the previous advice to assume that anything you haven't seen before is correct. That will cover you if the question is being counted!
Reading This Book
It might help to have some idea about how this book has been written. This section contains details about some of the common structures and features you find in this book, where to go for additional help, and how to obtain bonus material for this book.
Who Should Buy This Book
If you want to obtain the OCP 17 Java programmer certification, this book is definitely for you. If you want to acquire a solid foundation in Java and your goal is to prepare for the exam, then this book is also for you. You'll find clear explanations of the concepts you need to grasp and plenty of help to achieve the high level of professional competency you need in order to succeed in your chosen field.
This book is intended to be understandable to anyone who has a tiny bit of Java knowledge. If you've never read a Java book before, we recommend starting with a book that teaches programming from the beginning and then returning to this study guide.
This book is for anyone from high school students to those beginning their programming journey to experienced professionals who need a review for the certification.
How This Book Is Organized
This book is divided into 15 chapters, plus supplementary online material: a glossary of important terms, 500+ flash cards, and three practice exams that simulate the real exam.
Unlike the exam objectives, we organize our chapters organically so that each chapter builds on the material of the previous chapters. We also want to make things easier to learn and remember. This means some chapters cover multiple objectives.
The chapters are organized as follows:
Chapter 1: Building Blocks describes the basics of Java, such as how to run a program. It covers variables such as primitives, object data types, and scoping variables. It also discusses garbage collection.
Chapter 2: Operators explains operations with variables. It also talks about casting