java 8 jshell mock questions

I gave a presentation showing how to make mock exam questions. We used Java 9 JShell as the example. The idea was to pick a feature nobody knew much about. We started by picking key points from this blog. Then we made questions. This post is the results. (Edited for formatting, to alphabetize answers, after confirming, etc). Good job all!

Question 1

What does REPL stand for?

  1. Random Enterprise Process Logic
  2. Rapid Enterprise Process Line
  3. Rapid Execution of Programming Logic
  4. Read Evaluate Print Loop
  5. Read Evaluate Print Line
  6. Read Execute Print Loop

Question 2

When typing into JShell interactively, it uses ______.

  1. Nashorn
  2. JRE
  3. JS
  4. JVM
  5. REPL
  6. RPEL
  7. Streams

Question 3

Which of the following compiles when typed into JShell? (Choose all that apply)

  1. Class.forName(“String.class”)
  2. Class.forName(“String.class”);
  3. Thread.sleep(1000)
  4. Thread.sleep(1000);
  5. System.out.println(“hello”)
  6. System.out.println(“hello”);

Question 4

Which of the following compiles when typed into JShell? (Choose all that apply)

  1. void method() { throw new Exception(); }
  2. void method() { throw new RuntimeException(); }
  3. void method() throw Exception { throw new Exception(); }
  4. void method() throw Exception { throws new Exception(); }
  5. void method() throws Exception { throw new Exception(); }
  6. void method() throw Exception { throws new Exception(); }

Question 5

Which of the following compiles when typed into JShell? (Choose all that apply)

  1. System.out.println(“Hello Java”)
  2. System.out.println(“Hello Java”);
  3. public void method() { throw new Exception(); }
  4. public void method() { throw new Exception(); };
  5. public void method() {System.out.println(“Hello Java”)}
  6. public void method() {System.out.println(“Hello Java”);}
  7. public void method() {System.out.println(“Hello Java”);};

Question 6

What are valid statement terminators in JShell? (Choose all that apply)

  1. ;
  2. :
  3. \n
  4. None (just press enter)
  5. None of the above

Question 7

Which of the following lines will compile and display a value if it’s the first line you type after launching JShell? (Choose all that apply)

  1. 5 + 6
  2. a + b
  3. System.out.println(“Hello”);
  4. System.out.println(“Hello”)
  5. out.println(“Hello”)
  6. out.println(“Hello”);
  7. { System.out.println(7) }
  8. { System.out.println(7); }
  9. 6 + 6; 10
  10. None of the above

Question 8

Which of the following is valid code in JShell? (Choose all that apply)

  1. system.out.println(“hello world”);
  2. system.out.println(hello world);
  3. Println(“hello world”);
  4. “hello word”
  5. hello world
  6. Answer: 5+3
  7. 5f+3
  8. new String()

Question 9

What is the output of the code below if executed in JShell?(Check all that apply)

Integer a = 5;

Integer c = a + 10;

Integer a = 7

a

  1. Compiler Error
  2. Runtime error
  3. 7
  4. Error: Duplicate variable declaration
  5. None of the above

Question 10

Which of the following commands invokes the help command in Jshell?  Choose all that apply.

  1. /h
  2. /help
  3. /?
  4. ?
  5. f1
  6. ctrl-f1
  7. help

Question 11

How would you invoke help on a particular Jshell command?  Choose all that apply.

  1. /help=command
  2. /help:command
  3. /help command
  4. /he command
  5. /h command

Question 12

double area (double radius) {

return 3.14 * square(radius);

}

area(2)

What is the correct output?

  1. 6.28
  2. 6
  3. 7
  4. Attempted to call area(double) which cannot be invoked
  5. Attempted to call square which cannot be invoked

Answers

  1. Choice 4 – Read Evaluate Print Loop
  2. Choice 5 – REPL
  3. All 6 choices are correct. The first two throw an exception, but do compile.  (This question had public in the user group lab. I wrote this question and removed it after)
  4. Choices 2 and 5. The semicolon is only optional at the end of the statement; not within a block
  5. Choices 1, 2, 6 and 7. The last two give a warning about public not being allowed, but work. The others fail because of an exception or missing semicolon within a method.
  6. Choices 1 and 4. Semicolon terminates a statement or you can omit the terminator
  7. Choices 1, 3, 4, 8 and 9. The last one is tricky. It gets executed as two statements.
  8. Choices 4, 7 and 8. JShell is case sensitive; just like Java
  9. Choice 3. (In the user group lab, there was another choice about a warning for a duplicate variable. I couldn’t reproduce the warning so removed that choice to avoid ambiguity.)
  10. Choices 2 and 3. Isn’t memorization fun?
  11. Choices 3 and 4. More memorizing
  12. Choice 4. Creating the method works, but gives a warning that square(double) must be declared. Then calling area gives “attempted to call method area(double) which cannot be invoked until method square(double) is declared”

 

 

 

OCA / OCP 8 Programmer Certification Kit NOW SHIPPING!

certkit Jeanne and I thrilled to announce that our publisher, Wiley Sybex, has released our two Java 8 Study Guides together as a Java 8 Certification Kit! The Java 8 Certification Kit is now shipping! The Java 8 Certification Kit includes the following two books and is a 30% saving over buying them individually:

Between the two books, the Java 8 Certification Kit includes a total of:

  • More than 350 Review Questions
  • 40 Assessment Questions to evaluate your skill level
  • 6 Practice Exams (3 for OCA 8, 3 for OCP 8) totaling more than 300 questions
  • More than 450 Flash Cards
  • 2 Searchable Glossaries

If you want to become an Oracle Certified Professional, the Java 8 Certification Kit contains everything you need to complete the 1Z0-808 Exam and the 1Z0-809 Exam!

If you already hold a Java OCP 7 certification, the Java 8 Certification Kit will also help you pass the 1Z0-810 Exam. Finally, if you hold a Oracle or Sun Certification for Java 6 or older, the Java 8 Certification Kit provides a good refresher for everything you missed in the OCA 8 exam and contains an additional appendix to help you pass the 1Z0-813 Exam.

Oracle re-scores BETA OCP 8 Exam!

Oops!Oracle offered a beta version of the Oracle Certified Professional, Java 8 Programmer, exam number 1Z1-809, last spring. Approximately 11-weeks after the beta exam ended, they released the score reports in August 2015. As anyone who has taken a beta exam probably knows, there are often questions and objectives on the exam that are not finalized and even contain errors, which is why it takes so long to score.

We are receiving a number of reports than in January 2016, approximately 8 months after the exam ended, users who took the beta OCP 8 1Z1-809 exam are now receiving a completely different score. In at least one case, a user who previously failed the exam got a bump 10%+ points and is now shown as passing the exam.

While slight changes to scores of beta exams is nothing new, the time between the exam and the re-scoring, as well as the size of the adjustment, are definitely quite bizarre. If you did take this exam, we recommend logging into Oracle CertView to see if your score has changed.