On Saturday, January 18, 2010, I will be on stage at Oracle Code One 2019 Report Meeting in Osaka with the title "Oss! Oracle Code One". I did.
So, as an interesting session, I introduced the contents of the session "Duke's Star Trek with Java 12 Code Challenges".
Since Oracle Code One is a four-day conference from morning till night, I listen to many sessions, but there are too many sessions and I always have a hard time choosing a session. But as a Star Trek enthusiast, I made a reservation almost no time just by looking at the title. The content was to introduce the new features introduced in each version from JDK6 to JDK12 in a 4-choice quiz format, and it was a very good session that proceeded with fun slides with animation.
At the debriefing session, I introduced some of the quizzes I gave in this session (and the original I made for supplementation).
For example, in the introduction about JDK7
public class ShipDoorEp1 implements AutoCloseable {
public void open() { throw new RuntimeException("Fail to open door."); }
@Override
public void close() throws Exception {
System.out.println("Ship door is closed.");
}
public static void main(String... doorMalfunction) {
try (ShipDoorEp1 shipDoor = new ShipDoorEp1()) {
shipDoor.open();
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
System.out.println("The end.");
}
}
}
If you execute such code, it will be one of the following A, B, C, D. For the correct answer, see the material used at the debriefing session (link at the end of the article).
A) Fail to open door. The end. Ship door is closed.
B) Fail to open door. Ship door is closed. The end.
C) Ship door is closed. Fail to open door. The end.
D) Fail to open door. The end.
I think this problem is pretty easy, but I'll dig deeper in the session.
public class ShipDoorEp2 implements AutoCloseable {
public void open() { throw new RuntimeException("Fail to open door."); }
@Override
public void close() throws Exception {
throw new RuntimeException("Fail to auto-close door.");
}
public static void main(String... doorMalfunction) {
try (ShipDoorEp2 shipDoor = new ShipDoorEp2()) {
shipDoor.open();
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println(e.getSuppressed()[0].getMessage());
} finally {
System.out.println("The end.");
}
}
}
He also mentioned such suppressed exceptions. (Please check the materials for question options and answers)
Of course, there were many interesting sessions other than this session, but this session left the most impression on me because I was able to look back on the history of version upgrades from JDK6 to JDK12, which included various additions. I did.
I hope I can join Oracle Code One next year and listen to a good session.