Java Magazine, September/October 2016
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2016 58 fix this Ive put together more problems that simulate questions from the 1Z0 809 Programmer II exam which is the certification test for developers who have been certified at a basic level of Java 8 programming knowledge and now are looking to demonstrate more advanced expertise Readers wishing basic instruction should consult the New to Java column which appears in every issue Ed These questions might require careful deduction to obtain the right answer Question 1 Given this code public IntSupplier doStuff int vals int i line n1 return vals i Which two are true Choose two a The code compiles b The argument list must be changed to final int vals final int i to allow the code to compile c If the code if vals 0 0 vals i 0 is added at line n1 the argument list must be changed to final int vals final int i to allow the code to compile d The code if vals 0 0 vals i 0 can be added at line n1 without causing compilation errors e The code vals Arrays copyOf vals vals length can be added at line n1 without causing compilation errors Question 2 Given the following code public class Wrapper public class Wrapped Which is true Choose one a An instance of Wrapped can be created only by code inside the class Wrapper b An instance of Wrapped can be created using the expression new Wrapper Wrapped c An instance of Wrapped can be created using the expression new Wrapper Wrapped d An instance of Wrapped can be created using the expression new Wrapper new Wrapped e An instance of Wrapped can be created using the expression new Wrapper Wrapped Question 3 You wish to calculate the sum of the numbers in a stream and also print out each one So far you have this code public static int sumAndPrint IntStream is int total 0 is parallel peek v total v forEach System out println return total SIMON ROBERTS Quiz Yourself More subtle questions from an author of the Java certification tests
You must have JavaScript enabled to view digital editions.