1Z0-809 Premium Bundle

1Z0-809 Premium Bundle

Java SE 8 Programmer II Certification Exam

4.5 
(6000 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
November 21, 2024Last update

Oracle 1Z0-809 Free Practice Questions

Q1. Given the for loop construct: 

for ( expr1 ; expr2 ; expr3 ) { 

statement; 

Which two statements are true? 

A. This is not the only valid for loop construct; there exits another form of for loop constructor. 

B. The expression expr1 is optional. it initializes the loop and is evaluated once, as the loop begin. 

C. When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration through the loop. 

D. The expression expr3 must be present. It is evaluated after each iteration through the loop. 

Answer: B,C 

Explanation: 

The for statement have this forms: 

for (init-stmt; condition; next-stmt) { 

body 

There are three clauses in the for statement. 

The init-stmt statement is done before the loop is started, usually to initialize an iteration 

variable. 

The condition expression is tested before each time the loop is done. The loop isn't 

executed if the boolean expression is false (the same as the while loop). 

The next-stmt statement is done after the body is executed. It typically increments an 

iteration variable. 

Q2. Given the code fragment: 

Path path1 = Paths.get(“/app/./sys/”); 

Path res1 = path1.resolve(“log”); 

Path path2 = Paths.get(“/server/exe/”); 

Path res1 = path1.resolve(“/readme/”); 

System.out.println(res1); 

System.out.println(res2); 

What is the result? 

A. /app/sys/log /readme/server/exe 

B. /app/log/sys /server/exe/readme 

C. /app/./sys/log /readme 

D. /app/./sys/log /server/exe/readme 

Answer:

Q3. Given the code fragments: 

class Caller implements Callable<String> { 

String str; 

public Caller (String s) {this.str=s;} 

public String call()throws Exception { return str.concat (“Caller”);} 

class Runner implements Runnable { 

String str; 

public Runner (String s) {this.str=s;} 

public void run () { System.out.println (str.concat (“Runner”));} 

and 

public static void main (String[] args) InterruptedException, ExecutionException { 

ExecutorService es = Executors.newFixedThreadPool(2); 

Future f1 = es.submit (new Caller (“Call”)); 

Future f2 = es.submit (new Runner (“Run”)); 

String str1 = (String) f1.get(); 

String str2 = (String) f2.get();//line n1 

System.out.println(str1+ “:” + str2); 

What is the result? 

A. The program prints: 

Run Runner 

Call Caller : null 

And the program does not terminate. 

B. The program terminates after printing: 

Run Runner 

Call Caller : Run 

C. A compilation error occurs at line n1. 

D. An Execution is thrown at run time. 

Answer:

Q4. Given: 

public final class IceCream { 

public void prepare() {} 

public class Cake { 

public final void bake(int min, int temp) {} 

public void mix() {} 

public class Shop { 

private Cake c = new Cake (); 

private final double discount = 0.25; 

public void makeReady () { c.bake(10, 120); } 

public class Bread extends Cake { 

public void bake(int minutes, int temperature) {} 

public void addToppings() {} 

Which statement is true? 

A. A compilation error occurs in IceCream. 

B. A compilation error occurs in Cake. 

C. A compilation error occurs in Shop. 

D. A compilation error occurs in Bread 

E. All classes compile successfully. 

Answer:

Q5. Given the code fragments: 

class TechName { 

String techName; 

TechName (String techName) { 

this.techName=techName; 

and 

List<TechName> tech = Arrays.asList ( 

new TechName(“Java-“), 

new TechName(“Oracle DB-“), 

new TechName(“J2EE-“) 

); 

Stream<TechName> stre = tech.stream(); 

//line n1 

Which should be inserted at line n1 to print Java-Oracle DB-J2EE-? 

A. stre.forEach(System.out::print); 

B. stre.map(a-> a.techName).forEach(System.out::print); 

C. stre.map(a-> a).forEachOrdered(System.out::print); 

D. stre.forEachOrdered(System.out::print); 

Answer:

Q6. Given the fragments: 

Which line causes a compilation error? 

A. Line n1 

B. Line n2 

C. Line n3 

D. Line n4 

Answer:

Q7. Given the code format: 

Which code fragment must be inserted at line 6 to enable the code to compile? 

A. DBConfiguration f; return f; 

B. Return DBConfiguration; 

C. Return new DBConfiguration; 

D. Retutn 0; 

Answer:

Q8. Given: 

What is the result? 

A. 10 : 22 : 20 

B. 10 : 22 : 22 

C. 10 : 22 : 6 

D. 10 : 30 : 6 

Answer:

Q9. Given: 

class Sum extends RecursiveAction { //line n1 

static final int THRESHOLD_SIZE = 3; 

int stIndex, lstIndex; 

int [ ] data; 

public Sum (int [ ]data, int start, int end) { 

this.data = data; 

this stIndex = start; 

this. lstIndex = end; 

protected void compute ( ) { 

int sum = 0; 

if (lstIndex – stIndex <= THRESHOLD_SIZE) { 

for (int i = stIndex; i < lstIndex; i++) { 

sum += data [i]; 

System.out.println(sum); 

} else { 

new Sum (data, stIndex + THRESHOLD_SIZE, lstIndex).fork( ); 

new Sum (data, stIndex, 

Math.min (lstIndex, stIndex + THRESHOLD_SIZE) 

).compute (); 

and the code fragment: 

ForkJoinPool fjPool = new ForkJoinPool ( ); int data [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} fjPool.invoke (new Sum (data, 0, data.length)); 

and given that the sum of all integers from 1 to 10 is 55. Which statement is true? 

A. The program prints several values that total 55. 

B. The program prints 55. 

C. A compilation error occurs at line n1. 

D. The program prints several values whose sum exceeds 55. 

Answer:

Q10. You have been asked to create a ResourceBundle which uses a properties file to localize an application. 

Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu? 

A. <key name = ‘menu1”>File Menu</key> <key name = ‘menu2”>View Menu</key> 

B. <key>menu1</key><value>File Menu</value> <key>menu2</key><value>View Menu</value> 

C. menu1, File Menu, menu2, View Menu 

D. menu1 = File Menu menu2 = View Menu 

Answer:

Q11. Which statement is true about the DriverManager class? 

A. It returns an instance of Connection. 

B. it executes SQL statements against the database. 

C. It only queries metadata of the database. 

D. it is written by different vendors for their specific database. 

Answer:

Explanation: The DriverManager returns an instance of Doctrine\DBAL\Connection which is a wrapper around the underlying driver connection (which is often a PDO instance). Reference: http://doctrine-dbal.readthedocs.org/en/latest/reference/configuration.html 

Q12. Given the code fragment: 

List<String> empDetails = Arrays.asList(“100, Robin, HR”, 

“200, Mary, AdminServices”, 

“101, Peter, HR”); 

empDetails.stream() 

.filter(s-> s.contains(“1”)) 

.sorted() 

.forEach(System.out::println); //line n1 

What is the result? 

A. 100, Robin, HR 101, Peter, HR 

B. E. A compilation error occurs at line n1. 

C. 100, Robin, HR 101, Peter, HR 200, Mary, AdminServices 

D. 100, Robin, HR 200, Mary, AdminServices 101, Peter, HR 

Answer:

Q13. Given the definition of the Vehicle class: 

Class Vehhicle { 

int distance;//line n1 

Vehicle (int x) { 

this distance = x; 

public void increSpeed(int time) {//line n2 

int timeTravel = time;//line n3 

class Car { 

int value = 0; 

public void speed () { 

value = distance /timeTravel; 

System.out.println (“Velocity with new speed”+value+”kmph”); 

new Car().speed(); 

and this code fragment: 

Vehicle v = new Vehicle (100); 

v.increSpeed(60); 

What is the result? 

A. Velocity with new speed 

B. A compilation error occurs at line n1. 

C. A compilation error occurs at line n2. 

D. A compilation error occurs at line n3. 

Answer:

Q14. Given the code fragment: 

List<String> listVal = Arrays.asList(“Joe”, “Paul”, “Alice”, “Tom”); 

System.out.println ( 

// line n1 

); 

Which code fragment, when inserted at line n1, enables the code to print the count of string elements whose length is greater than three? 

A. listVal.stream().filter(x -> x.length()>3).count() 

B. listVal.stream().map(x -> x.length()>3).count() 

C. listVal.stream().peek(x -> x.length()>3).count().get() 

D. listVal.stream().filter(x -> x.length()>3).mapToInt(x -> x).count() 

Answer:

Q15. Given: 

What is the result? 

A. Null 

B. Compilation fails 

C. An exception is thrown at runtime 

D. 0 

Answer:

START 1Z0-809 EXAM