Happy Book Birthday! OCP 17 Practice Tests

Our Java 17 Practice Tests book has been released! This is a major rewrite of our Java OCP 11 book with hundreds of new and revised questions! If you already have our Java 17 Study Guide, you can purchase it individually, or you can buy it as kit.

The Practice Tests OCP 17 book contains 11 chapters helping you review and reinforce each objective. It also includes 3 full practice exams. All questions in the practice test book are unique from those in the complete study guide.

Interesting change in calling methods in Java 17

We have this code in our Java 11 practice exam book. What do you think it prints?

public class Hippo {
    private static void hippo(short num1, short num2) {
        System.out.println("shorts");
    }
    private static void hippo(int... nums) {
        System.out.println("varargs");
    }
    private void hippo(long num1, long num2) {
        System.out.println("longs");
    }
    private void hippo(int num1, int num2) {
        System.out.println("nums");
    }
    public static void main(String... args) {
        hippo(1, 5);
    } }

Reasoning it through, we know, it doesn’t print longs or nums because the main() is static and therefore we can’t be calling an instance methods. The answer is varargs because we have ints. This seems nice and reasonable.

I then ran the same code in Java 17 and it doesn’t compile!

% java17 Hippo.java
Hippo.java:15: error: non-static method hippo(int,int) cannot be referenced from a static context
hippo(1, 5);
^
1 error
error: compilation failed

i do agree that hippo(int, int) can’t be called. I was surprised at the behavior where it no longer compiles. If I remove the two instance variables, Java still prints varargs like I was expecting.

Happy Book Birthday! OCP Java 17 Book Released!

Jeanne and I over the moon to announce the release of our new OCP Java 17 Developer Complete Study Guide! This book is the culmination of years of knowledge that we’ve accumulated writing study guides for Java. It is for anyone who wants to expand their knowledge of Java, or who wants to pass Oracle’s new Java SE 17 Developer 1Z0-829 exam and become a Java 17 Oracle Certified Professional.

Lambdas and streams? Covered! Concurrency, JDBC, and NIO.2? Covered! New Java 17 switch expressions, records, sealed classes, pattern matching? Definitely covered! Modules? Ok, we don’t use them much either, but they are covered for the exam! It’s great for those who are familiar with Java, but want to acquire a deeper understanding of the language. Learn features of the language that will help you write better code!

Our Java 17 book is a streamlined version of our previous books, including all of the new material and changes that you need to know for the exam. Previously, we wrote one book for each of the two exams. Starting with Java 17, there’s only one exam, allowing us to cover the material in a much more concise and straight-forward manner. Put simply, it weighs less than our previous Complete Study Guide!

Want to win a free copy? Our home away from home, CodeRanch, will be running a book promotion next week starting on May 10th!