Java Practice Questions: Upgrade to Java SE 7 Programmer by Esteban Herrera - Read Online
Java Practice Questions
0% of Java Practice Questions completed



This book contains 120 questions for exam IZ0-805, Oracle Certified Professional Upgrade to Java SE 7 Programmer. It will help you to:

Know what is covered by the exam.
Increase your chances to pass the exam by practicing with similar questions.
Strengthen your knowledge of the six topics covered by the exam.

Including 20 questions for each exam topic, this book doesn't claim to have the largest number of practice questions. It claims to have questions that will help you pass the upgrade exam. It focuses in quality, not quantity.

Each question was chosen to test a particular point of every exam objective. They are not just filler questions that have no relation with the exam. Explanations for the answer(s) of every question are included.

Even if you are not interested about the upgrade exam, this book will help you learn or practice the new things that came with version 7 of Java.

The book was carefully formatted (especially in the questions with code snippets) to provide the best experience as an e-book.

Published: Esteban Herrera on
ISBN: 9781501430282
List price: $5.99
Availability for Java Practice Questions: Upgrade to Java SE 7 Programmer
With a 30 day free trial you can read online for free
  1. This book can be read on up to 6 mobile devices.


Book Preview

Java Practice Questions - Esteban Herrera

You've reached the end of this preview. Sign up to read more!
Page 1 of 1

Java Practice Questions: Upgrade to Java SE 7 Programmer


Esteban Herrera

Copyright © 2013 by Esteban Herrera

All rights reserved.

No part of this publication can be reproduced or transmitted in any form or by any means, electronic or mechanical, without permission in writing from the author.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

This publication is provided as is without warranty of any kind, either express or implied, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. This publication could include technical inaccuracies or typographical errors. Changes are periodically added to the information herein.

The author has taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.


Practice Questions Section 1: Language Enhancements

Practice Questions Section 2: Design Patterns

Practice Questions Section 3: Database Applications with JDBC

Practice Questions Section 4: Concurrency

Practice Questions Section 5: Localization

Practice Questions Section 6: Java File I/O (NIO.2)

Answers Section 1. Language Enhancements

Answers Section 2. Design Patterns

Answers Section 3. Database Applications with JDBC

Answers Section 4. Concurrency

Answers Section 5. Localization

Answers Section 6. Java File I/O (NIO.2)


Java programmer exams are hard and tricky.

But you already know that. You know that experience in the language, most of the time, is not enough to pass the exam. That is because you must not only be deeply familiar with the features of Java, you also have to understand why some things are the way they are and when and how to use them properly. Like I always say, you must have a java compiler inside your head to pass these exams.

Starting from Java SE 7, Oracle has broken the programmer certification (the base of all other certifications about Java) in two exams.

The first one, the Oracle Certified Associate Java SE 7 Programmer exam, covers the basics of the language and concepts of object-oriented programming to create simple Java applications. Passing this exam is required to take the second, the Oracle Certified Professional Java SE 7 Programmer exam which covers advanced concepts and functionality. However, if you want to get certified as a Java 7 programmer and you hold a certification of any previous version of Java, you don't need to pass those exams, you just need to take an upgrade exam.

How to use this book

This book should not be your only resource if you are planning to take the upgrade to the Java SE 7 Programmer exam. It is just intended to be a supplement. A good strategy to pass the exam would be the following:

Take a course that covers all the topics of the exam or study with a good study guide.

Practice all you can with mock exams.

The purpose behind this book is to help you with the second point. There are many mock exams and simulators offered by companies that claim to have a lot of questions and drills. The problem with most of them is that many of those questions have nothing to do with the topics covered by the exam, are ambiguous, repetitive or simply are just too easy compare it to the real test.

In contrast, this book presents for each of the six major topics covered by the exam, 20 well-thought questions properly formatted, each with a link to its answer and an explanation. You can try to answer the question by yourself and after that see if you got the correct answer before proceeding to the next or answer all the questions within a section, record your answers somewhere and then see how many of them you got right. For all the wrong answers, you can go back to study the topic covered by each question until you master it.

Further, I offer you some tips to pass the exam:

Write a lot of code, but don't use an IDE (they make your life easier at work, but not for the purpose of study to pass the exam).

Don't rush through the exam. Do not read the question too quickly; try to fully understand what the question is asking before answer it.

In questions that involve source code, first of all, check if the code compiles correctly.

Study one topic at a time.

Give yourself enough time to study. Avoid cramming.

Be sure to check out It has the best certification forums and a great community.

If you have doubts about the questions presented in this book, you can visit the site to find information or contact the author.

If you like or find this book helpful, please recommend it. If you don't, please give some feedback to improve it. And let me know how you did in the exam. Good luck.

Esteban Herrera

Practice Questions Section 1: Language Enhancements


Develop code that uses String objects in switch statements

Develop code that uses binary literals and numeric literals with underscores

Develop code that uses try-with-resources statements (including using classes that implement the AutoCloseable interface)

Develop code that handles multiple Exception types in a single catch block

Develop code that uses the diamond with generic declarations

1.1. Given:

public class Test {

  public void m(List l) {



  public void m1() {

    List l = new ArrayList<>(); //1




    m(new ArrayList<>()); //2


  public static void main(String[] args) {

    Test obj = new Test();




What is the result when you execute class Test? (Assuming the correct imports)

A. Compilation fails at line marked by //1

B. Compilation fails at line marked by //2

C. 20

D. None of the above.

View Answer

1.2. Given:

public class Test {

  enum Constants {



  public static void main(String[] args) {



    Constants c = Constants.LETTERS;

    switch(c) {

      case LETTERS:


      case NUMBERS:







What is the result when you execute this program?




D. Compilation fails.

View Answer

1.3. Given:

public class Test {

  public static void main(String[] args) {

    int a = 123_498;

    long b = 0xAAAA_ABCD;

    float c = 324_35._932F;




What is the result (or the first error) when you execute this program?

A. Compilation error in the declaration of variable a.

B. Compilation error in the declaration of variable b.

C. Compilation error in the declaration of variable c.

D. 123498

E. 123_498

View Answer

1.4. Which of the following types of values cannot be an argument to a switch statement? Choose all that apply.

A. long

B. short

C. char

D. StringBuilder

E. enum

F. boolean

View Answer

1.5. Which of the following are TRUE statements? Choose all that apply.

A. The try-with-resources statement can declare more than one resource that