It is more than a year ago that I successfully passed my Oracle Certified Professional SE 11 exam and as I have an upcoming interview, I thought it would be a good idea to write a short recap of it so I can easily tell about the concepts I’m familiar with.

What I do here is creating a very brief summary of the book, enough to have hints about what it was all about. The main parts have to do with the more advanced topics, ie generics, creating services, concurrency, JDBC details and serialization.

Part I

The first part was the more easy part. These are the chapters with some keywords:

Chapter 7: Methods and Encapsulation

  • Varargs, accerss modifiers, static keyword
  • Data is passed by value
  • Overloading
  • Encapsulating (using getters /private instance fields)

Chapter 8: Class Design

  • Inheritance
  • this and super
  • this() and super()
  • Constructors and inheritance
  • Inheriting members
  • Polymorphism
  • protected allows subclasses to inherit, package-private does not

Chapter 9: Advanced Class Design

  • Abstract classes
  • Interfaces
  • Inner classes

Chapter 10: Exceptions

  • Throwable, Error, Exception, RuntimeException
  • throw vs throws
  • Chaining catch blocks
  • Multicatch block
  • Try-with-resources
  • Resources closed in reverse order of opening

Chapter 11: Modules

  • Exports, requires, requires transitive
  • Provides, uses, opens
  • provides communicates the availabiltiy of an implementation of some external interface
  • uses X tells you that the module depends on service/interface X
  • opens tells a package is accessible for reflection
  • java.base module is available to other jdk modules by default
  • Inspecting/listing modules via command line
    • –describe-module
    • –list-modules
    • –show-module-resolution
    • jdeps -summary

Part II

Chapter 12: Java Fundamentals

  • Rules for final modifier
  • Enums
  • Nested classes
    • inner class
    • static nested class
    • local class
    • anonymous class
  • Permitted interface members
  • Functional interface /single abstract method
  • Functional programming
  • Syntax of lambda expressions

Chapter 13: Annotations

  • Create custom annotations, syntax
  • Elements with and without default value (required vs optional)
  • Permitted element types: primitive, String, Class, enum, another annotation, an array of any of these types.
  • Adding constant variables (public static final int MAX_SIZE = 100 or just int MAX_SIZE = 100)
  • value() element for short notation:
    • there must be an element value(), which can be optional (having a default value) or required
    • there can be no required element other than value()
    • annotation usage must not provide values for any other elements
  • Annotation-specific annotations:
    • @Target
    • @Retention (SOURCE, CLASS, RUNTIME)
    • @Documented
    • @Inherited
    • @Repeatable (requires some special syntax with extra annotation)
  • Common annotations:
    • @Override
    • @FunctionalInterface
    • @Deprecated
    • @SuppressWarnings
    • @safeVarargs

Chapter 14: Generics and Collections

  • List of 8 functional interfaces from java library
  • Method references
  • Wrapper classes, autoboxing, unboxing
  • Be careful whan calling remove(2) on a List<Integer>. It removes the third item in the collection.
  • Diamond operator
  • Lists, Sets, Maps and Queues
  • Comparable vs Comparator
  • Comparable must be implemented by class to be compared. Its compareTo() method has 1 parameter.
  • Comparator: its compare() method has 2 parameters. Use Comparator in lambda’s.
  • Comparator can be designed by chaining static methods.
  • Generic classes: syntax
  • Generic interfaces, how to implement them
  • Type erasure makes objects nonreifiable, preventing certain uses
  • What a raw type is
  • Generic methods: syntax
  • Wildcards: unbounded, upper bound, lower bound

Chapter 15: Functional Programming

  • Built-in functional interfaces (9)
  • Using method references
  • Chaining static methods that are found in built-in functional interfaces (and(), andThen(), negate() etc)
  • Optional<T> with its methods
  • Stream<T>, stream(), parallelStream()
  • Infinite streams, limit(), iterate()
  • Terminal operations
  • How reduce(), collect() works
  • Collectors (grouping, joining, mapping, partitioning)
  • flatMap() (this is the most difficult one)
  • Working with primitive streams
  • Mapping between stream types

Chapter 16: Exceptions, Assertions and Localizations

  • Checked exception: handle or declare
  • Create custom exceptions
  • Try-with-resources source types require AutoClosable or Closable interface
  • Try-with-resources clause can use effectively final resources declared before the try statement. This option exists but caution is warranted
  • Suppressed exceptions (only the exception on last declared resource is thrown in case of multiple exceptions)
  • Assertions: assert is a keyword
  • assert throws AssertionError, unrecoverable
  • Assert statements are disabled by default. Turn them on with - enableassertions or -ea.
  • You can enable assertions for only a specific class or package(s)
  • You can combine -ea flag with -da flag (disable assertions) if you want to exclude some classes/packages
  • Dates and times:
    • java.time.LocalDate
    • java.time.LocalTime
    • java.time.LocalDateTime
    • java.time.ZonedDateTime
  • Static of(..) method lets you create specific time/date object
  • Static now() gives current date/time
  • Class DateTimeFormatter helps to display standard formats
  • Book contains table with all common date/time symbols
  • Locale locale = Locale.getDefault() returns something like en_US. First is language, second country. First (en) is required, second (US) is optional.
  • Locale has a static Builder class.
  • NumberFormat has methods to format numbers in local style. These methods have Locale as parameter or rely on default locale.
  • ResourceBundle class lets you import data from .properties files. These .properties files can reside outside of the jar file.
  • java.util.Properties is a sort of HashMap used for storing properties. Key and value are of type String. It has the ‘setProperty() and getProperty()` methods.

Chapter 17: Modular Applications

  • Named modules, automatic modules, unnamed modules
  • The latter one appears on the classpath instead of the module path.
  • Automatic module misses module-info file. Name is either provided in MANIFEST or generated based on name of JAR file
  • Code on classpath can access code on module path but not the other way around
  • jdeps is used against JAR files. It tells what modules the application relies on, and is specific about the requested packages within these modules.
  • Using the –jdk-internals flag with jdeps tells about the unsupported api’s that your JAR might use (like jdk.unsupported).
  • How to migrate to modular system. Start with the independent module and work further up the dependency graph. Reason for this order is that named modules on the module path cannot access the unnamed modules on the classpath.
  • You can also work top down. Move everything to the module path and add a module-info file to the most dependent module first. The higher level named module will have access to the lower level automatic modules.
  • Circular dependencies in modules are not allowed and will not compile
  • Creating a service requires the following:
    • a Service Provider Interface
    • a Service Locator (uses ServiceLoader class with load() method)
    • a Service Provider (implements the interface)
    • a Consumer (calls the Service Locator)
  • The above requires proper module-info statements. Service Locator needs a ‘uses’ statement.

Chapter 18: Concurrency

  • Authors encourage you to use the new Concurrency api
  • But you can use the classic (new Thread(new ClassImplementingRunnable())).start(). The task is defined in the run() method of specified class.
  • Another classic way is extending the Thread class with an override for its run() method
  • Be aware that you need use start() and not run() on the Thread object to start the task in a new thread. Using run() keeps things synchronous.
  • “polling is the process of intermittently checking data at some fixed interval.” Thread.sleep() allows for intervals between polling.
  • Concurrency api manages threads better than you can do yourself. Obtain an ExecutorService interface object and use it.
  • Static factories that provide different implementations for ExecutorService are found in class Executors. Some single threaded, others multithreaded. The latter create some thread pool.
  • The ExecutorService object must be shut down after work is done, otherwise your program will never end. There are several methods that shut things down, some with more force than others.
  • ExecutorService has both an execute() and a submit() method to submit tasks. The latter method returns a Future<V> object you can use to track the results. Author recommends submit(). V is the return type of the Runnable.run() method (which is void).
  • Instead of Runnable you can use Callable<V> that has a call() method. This method has a V return value and no parameters.
  • Use Future<.> result = service.submit(Callable c)
  • The awaitTermination() method returns when all tasks are finished, or when a set time limit is reached. Use shutdown() before awaitTermination().
  • You can supply a collection of tasks to ExecutorService with invokeAll() and invokeAny()
  • ScheduledExecutorService is a child of ExecutorService. It allows you to schedule tasks in the future.
  • ScheduledExecutorService works with a ScheduledFuture object that tracks progress. ScheduledFuture is similar to Future.
  • AtomicBoolean, AtomicInteger and AtomicLong. They have their own method for getting, setting, incrementing and decrementing.
  • Using synchronized block


<
Previous Post
Method analysis
>
Next Post
Git