1Z0-809 | A Review Of Approved 1Z0-809 braindumps


Q51. Given the code fragment: 

public class FileThread implements Runnable { 

String fName; 

public FileThread(String fName) { this.fName = fName; } 

public void run () System.out.println(fName);} 

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

ExecutorService executor = Executors.newCachedThreadPool(); 

Stream<Path> listOfFiles = Files.walk(Paths.get(“Java Projects”)); 

listOfFiles.forEach(line -> { 

executor.execute(new FileThread(line.getFileName().toString())); // 

line n1 

}); 

executor.shutdown(); 

executor.awaitTermination(5, TimeUnit.DAYS);// 

line n2 

The Java Projects directory exists and contains a list of files. 

What is the result? 

A. The program throws a runtime exception at line n2. 

B. The program prints files names concurrently. 

C. The program prints files names sequentially. 

D. A compilation error occurs at line n1. 

Answer:

Q52. Which two statements are true for a two-dimensional array of primitive data type? 

A. It cannot contain elements of different types. 

B. The length of each dimension must be the same. 

C. At the declaration time, the number of elements of the array in each dimension must be specified. 

D. All methods of the class object may be invoked on the two-dimensional array. 

Answer: C,D 

Explanation: http://stackoverflow.com/questions/12806739/is-an-array-a-primitive-type-or-an-object-or-something-else-entirely 

Q53. Given: 

public class Counter { 

public static void main (String[ ] args) { 

int a = 10; 

int b = -1; 

assert (b >=1) : “Invalid Denominator”; 

int = a / b; 

System.out.println (c); 

What is the result of running the code with the –ea option? 

A. -10 

B. 0 

C. An AssertionError is thrown. 

D. A compilation error occurs. 

Answer:

Q54. Given: 

public class SampleClass { 

public static void main(String[] args) { 

AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new 

SampleClass(); 

sc = asc; 

System.out.println("sc: " + sc.getClass()); 

System.out.println("asc: " + asc.getClass()); 

}} 

class AnotherSampleClass extends SampleClass { 

What is the result? 

A. sc: class Object asc: class AnotherSampleClass 

B. sc: class SampleClass asc: class AnotherSampleClass 

C. sc: class AnotherSampleClass asc: class SampleClass 

D. sc: class AnotherSampleClass asc: class AnotherSampleClass 

Answer:

Q55. Given: 

public interface Moveable<Integer> { 

public default void walk (Integer distance) {System.out.println(“Walking”);) 

public void run(Integer distance); 

Which statement is true? 

A. Moveable can be used as below: 

Moveable<Integer> animal = n - > System.out.println(“Running” + n); 

animal.run(100); 

animal.walk(20); 

B. Moveable can be used as below: 

Moveable<Integer> animal = n - > n + 10; 

animal.run(100); 

animal.walk(20); 

C. Moveable can be used as below: 

Moveable animal = (Integer n) - > System.out.println(n); 

animal.run(100); 

Moveable.walk(20); 

D. Movable cannot be used in a lambda expression. 

Answer:

Q56. Given the code fragment: 

LocalDate valentinesDay =LocalDate.of(2015, Month.FEBRUARY, 14); 

LocalDate nextYear = valentinesDay.plusYears(1); 

nextYear.plusDays(15); //line n1 

System.out.println(nextYear); 

What is the result? 

A. 2021-02-14 

B. A DateTimeException is thrown. 

C. 2021-02-29 

D. A compilation error occurs at line n1. 

Answer:

Q57. 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:

Q58. Given: A. ns = 50 S = 125 ns = 125 S = 125 ns = 100 S = 125 

B. ns = 50 S = 125 ns = 125 S = 125 ns = 0 S = 125 

C. ns = 50 S = 50 ns = 125 S = 125 ns = 100 S = 100 

D. ns = 50 S = 50 ns = 125 S = 125 ns = 0 S = 125 

Answer:

Q59. Given: 

What is the result? 

A. Good Day! Good Luck! 

B. Good Day! Good Day! 

C. Good Luck! Good Day! 

D. Good Luck! Good Luck! 

E. Compilation fails 

Answer:

Q60. Given: 

class UserException extends Exception { } 

class AgeOutOfLimitException extends UserException { } 

and the code fragment: 

class App { 

public void doRegister(String name, int age) 

throws UserException, AgeOutOfLimitException { 

if (name.length () < 6) { 

throw new UserException (); 

} else if (age >= 60) { 

throw new AgeOutOfLimitException (); 

} else { 

System.out.println(“User is registered.”); 

public static void main(String[ ] args) throws UserException { 

App t = new App (); 

t.doRegister(“Mathew”, 60); 

What is the result? 

A. User is registered. 

B. An AgeOutOfLimitException is thrown. 

C. A UserException is thrown. 

D. A compilation error occurs in the main method. 

Answer: