On passing Java Gold SE 8

Introduction

This time, I took the Java SE 8 Programmer II (Gold) on a certain day in November and passed it successfully.

There are various passing experiences in this Qiita, and I think that I thought about taking the Gold exam around May, so I don't think I was able to study efficiently as a compliment.

However, I feel that I was able to dig deeper into the process and ideas of the operation over time. Actually, it was not a perfect score, but I was able to follow the process and solve the problem while chewing.

In getting the qualification, it was a good experience to be able to absorb the problem collection as my own knowledge without relying on the dark clouds.

In this article, I will follow the content that I found interesting regardless of the frequency.

Stream Pipeline

The Stream API is unavoidable when taking the Gold exam, but it has a mechanism that makes the operation flow seemingly misleading. However, once you understand it, I think it will be useful for Stream-related problems.

An example is shown below.

example.java


public class example{
  public static void main(String[] args){
    Stream<String> fruit = Stream.of("banana", "grape", "orange","apple");
      .filter(s -> s.length() > 5)
      .peek(System.out::print)
      .map(String::toUpperCase)
      .peek(System.out::print);
    long l = fruit.count();
  }
}

Since the termination operation count is shown, the intermediate operation defined in fruit is executed with a delay. So how are each element of the Stream processed?

At the beginning of learning, I imagined the following flow.

図1.png

That is, I thought that all the elements would be verified for each intermediate operation. If this is correct, the output should be bananaorangeBANANA ORANGE. At first glance it seems correct.

However, in reality, it was different, ** the elements defined in Stream.of were manipulated one by one to the end, and then moved to the next element **. 図2.png In other words, the execution order of peek is ② → ④ → ⑦ → ⑨, so the output is bananaBANANAorangeORANGE.

You may not need to be aware of it when actually using Stream, but once you understand the flow of the operation order, you can unravel it without moving even if the appearance changes a little. It should be noted that if there is no termination operation count, nothing is output because Stream is only an intermediate operation. It is often asked that the termination operation is described correctly. (I feel that there were a lot of optional entanglements)

multi-catch and try-with-resources

There are a few questions in the areas of exceptions and assertions, but I don't want to miss them because they are easier to remember than the other items. It is a place that cannot be avoided even in practice (I think), so I think it is a field where learning can definitely be utilized.

First, the multi-catch introduced in SE7. This is a syntax that allows exception handling to be described collectively by separating them with "|". There are two points to note here.

** 1. Exceptions in inheritance relationship (polymorphic) cannot be listed together ** For example, writing ʻIOException and ʻException together will result in a compile error.

** 2. One variable ** Even if there are many exceptions to be listed together, there is only one variable at the end. If you write more than one, a compile error will occur.

catch(IOException e1 | InterruptedException e2){} //Compile error

Also, if you have multiple catch clauses, you can't put a subclass exception after a superclass exception (because it's caught in front and can't be checked).

Next, this is also a try-with-resource statement introduced in SE7. This is a syntax that provides a mechanism that can automatically close what was described in the finally clause (ex.FileReader) before SE 6.

The mechanism is applied by defining the resource in the back bracket of try as shown below.

try(FileReader fr = new FileReader("sample1.txt");
  FileWriter fw = new FileWriter("sample2.txt")){
  //Reading and writing resources
}catch(IOException e){
  //Exception handling
}

Here, ** the order of closing is the reverse of the defined order **. Also, if the resource does not implement ʻAutoClosable or Closable, such as when the resource is defined independently, a compile error will occur. Classes commonly used in I / O can be executed without problems because they implement ʻAutoClosable.

ForkJoinPool

ForkJoinPool defines three types of execution methods. Of these, only invoke synchronizes processing.

Also, in the case of asynchronous, the execution method changes depending on the return value. It is summarized below.

Method name Return value Sync/非Sync Inheritance class
execute void asynchronous RecursiveAction
invoke T Sync RecursiveAction/RecursiveTask<V>
submit ForkJoinTask<T> asynchronous RecursiveTask<V>

Looking at the method you are using, if it is invoke, the result will be unique, otherwise it will be undefined.

Scrollable ResultSet

ResultSet in JDBC allows you to define a mechanism that allows you to move the cursor freely.

//Statement definition for using scrollable ResultSet
Statement createStatement(int resultType, int resultSetConcurrency) throws SQLException

The constants that can be defined for the first and second arguments are defined in the ResultSet interface.

--First argument --TYPE_FORWARD_ONLY: Move only forward --TYPE_SCROLL_INSENSITIVE: Scrollable, DB not reflected --TYPE_SCROLL_SENSITIVE: Scrollable, DB reflected --Second argument --CONCUR_READ_ONLY: Cannot be updated ResultSet --CONCUR_UPDATABLE: Updatable ResultSet

Two arguments are required, so writing only one will result in a compile error.

In case of updatable ResultSet, if the primary key is set in the target table, each operation of Insert, Update and Delete is possible, but ** ʻinsertRow / ʻupdateRow / deleteRow method must be called. If it is not actually reflected in the DB **.

in conclusion

Compared to Silver, I feel that Gold was required to have a considerable amount of memorization and deep understanding. It was often too much and depressing. However, since it is good at my own pace, I think that it is a qualification that can be sufficiently acquired if you take the time to work on it. The exam fee is a bottleneck ... </ font>

I was able to pass the study by Kuromoto in the references. If you only consider the exam, this book and the official API check are sufficient. If you want a deeper understanding and a complete correct answer, you may want to consider purple books ...

I think there is no loss in taking on the challenge. If you are thinking of learning java, let's aim to acquire Silver and Gold!

References

[Thorough capture Java SE 8 Gold problem collection [1Z0-809] correspondence](https://www.amazon.co.jp/%E5%BE%B9%E5%BA%95%E6%94%BB%E7% 95% A5-Java-Gold-% E5% 95% 8F% E9% A1% 8C% E9% 9B% 86-1Z0-809 / dp / 4295000035)

Recommended Posts

On passing Java Gold SE 8
Story of passing Java Gold SE8
I took Java SE8 Gold.
Java SE Bronze (1Z0-818) Passing Experience
Oracle Certified Java Programmer, Gold SE 8
[Qualification] Java Silver SE11 Passing Experience
Java SE Overview
Oracle Certified Java Silver SE 8 Passing Experience
Java SE 7 memo
Java SE Subscription
[Qualification Exam] (Java SE8 Gold) Learning Review & Summary
[Java certification] Freshly picked! SE 11 Silver Passing Experience (2020/12/26)
How to get and study java SE8 Gold
Let's touch on Java
Passed Java SE8 Silver
Install Java on Mac
Java Silver passing experience
Run PostgreSQL on Java
java se 8 programmer Ⅰ memo
[java] Java SE 8 Silver Note
Java Gold Countermeasures: Format
Java8 Gold exam memorandum
Java Gold Countermeasures: Localization
[Java Silver] Study method that passed Java SE 8 Silver [Passing experience]
Java SE Development Kit (JDK) setup procedure on Windows
Story of passing Java Silver SE8 (Oracle Certified Java Programmer, Silver SE 8)
Java SE 8 Sliver exam questions
I started Java Gold (Chapter 1-1)
Install OpenJDK7 (JAVA) on ubuntu 14.04
Downgrade Java on openSUSE Linux
Reflection on Java string manipulation
Oracle Java 8 on Docker Ubuntu
Install Java on WSL Ubuntu 18.04
Run java applet on ubuntu
Put Oracle Java 8 on CircleCI 2
Java SE8 Silver Pass Experience
[Spring Security] Spring Security on GAE (SE)
Java version change on CentOS
What you learned when you acquired Java SE 8 Silver and Gold
Install java 1.8.0 on Amazon linux2
Let's talk about the passing experience of Java SE 8 Programmer II
The behavior of JS running on `Java SE 8 Nashorn` suddenly changed
Run Java EE applications on CICS
Using Java on OSX 10.15 (Catalina) β
How to study Java Silver SE 8
Consideration on Java Persistence Framework 2017 (Summary) -1
Consideration on Java Persistence Framework 2017 (6) Ebean
[Note] Java Silver SE8 qualification acquired
Install Java with zip on Windows
Get Java Silver on your commute!
Consideration on Java Persistence Framework 2017 (5) Iciql
[Java] How to update Java on Windows
Road to Java SE 11 Silver acquisition
Consideration on Java Persistence Framework 2017 (7) EclipseLink
Install Java Open JDK 8 on CentOS 7
Is Java on AWS Lambda slow?
Hello World on AWS Lambda + Java
Notes on signal control in Java
Consideration on the 2017 Java Persistence Framework (1)
Consideration on Java Persistence Framework 2017 (8) Hibernate5
Java SE Bronze exam test content