1z0-809 Braindumps PDF, Oracle 1z0-809 Exam Cram
New 2021 1z0-809 Sample Questions Reliable 1z0-809 Test Engine
NEW QUESTION 23
Given the code fragment:
public static void main (String[] args) throws IOException {
BufferedReader brCopy = null;
try (BufferedReader br = new BufferedReader (new FileReader("employee.txt"))) { // line n1 br.lines().forEach(c -> System.out.println(c)); brCopy = br;//line n2
}
brCopy.ready(); //line n3;
}
Assume that the ready method of the BufferedReader, when called on a closed BufferedReader, throws an exception, and employee.txt is accessible and contains valid text.
What is the result?
- A. A compilation error occurs at line n3.
- B. A compilation error occurs at line n1.
- C. The code prints the content of the employee.txt file and throws an exception at line n3.
- D. A compilation error occurs at line n2.
Answer: B
NEW QUESTION 24
Which two statements are true about localizing an application?
- A. Support for new regional languages does not require recompilation of the code.
- B. Language and region-specific programs are created using localized data.
- C. Language codes use lowercase letters and region codes use uppercase letters.
- D. Resource bundle files include data and currency information.
- E. Textual elements (messages and GUI labels) are hard-coded in the code.
Answer: A,C
NEW QUESTION 25
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?
User is registered.
- A.
- B. An AgeOutOfLimitExceptionis thrown.
- C. A compilation error occurs in the mainmethod.
- D. A UserExceptionis thrown.
Answer: B
NEW QUESTION 26
Given:
And given the code fragment:
What is the result?
- A. C2C2
- B. C1C2
- C. Compilation fails.
- D. C1C1
Answer: C
NEW QUESTION 27
Which statement is true about the DriverManager class?
- A. it executes SQL statements against the database.
- B. It returns an instance of Connection.
- C. It only queries metadata of the database.
- D. it is written by different vendors for their specific database.
Answer: B
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
NEW QUESTION 28
Given the code fragment:
public class ForTest {
public static void main(String[] args) {
int[] arrar = {1,2,3};
for ( foo ) {
}
}
}
Which three are valid replacements for foo so that the program will compiled and run?
- A. ; i < 1; i++
- B. ;;
- C. ; i < 1;
- D. int i: array
- E. int i = 0; i < 1; i++
Answer: B,D,E
NEW QUESTION 29
Given the code fragment:
Which code fragment, when inserted at line 9, enables the code to print true?
- A. String str2 = new String (str1);
- B. String str2 = sb1.toString ( );
- C. String str2 = "Duke";
- D. String str2 = str1;
Answer: D
Explanation:
StringBuilder sb1 = new StringBuilder("Duke");
String str1 = sb1.toString();
String str2 = str1;
//String str2 = "Duke";
//String str2 = new String(str1);
System.out.println(str1 == str2);
}}
NEW QUESTION 30
Given the following classes:
And given the following main method:
Which two options fail to compile when placed at line n1 of the main method?
- A. director .salary = 80_000;
- B. director .stockoptions = 1_000;
- C. employee .budget = 200_000;
- D. employee .salary = 50_000;
- E. manager .stockoption = 500;
- F. manager .budget = 1_000_000;
Answer: C,E
NEW QUESTION 31
Given the definition of the Emp class:
public class Emp
private String eName;
private Integer eAge;
Emp(String eN, Integer eA) {
this.eName = eN;
this.eAge = eA;
}
public Integer getEAge () {return eAge;}
public String getEName () {return eName;}
}
and code fragment:
List<Emp>li = Arrays.asList(new Emp("Sam", 20), New Emp("John", 60), New Emp("Jim", 51)); Predicate<Emp> agVal = s -> s.getEAge() <= 60;//line n1 li = li.stream().filter(agVal).collect(Collectors.toList()); Stream<String> names = li.stream()map.(Emp::getEName);//line n2 names.forEach(n -> System.out.print(n + " ")); What is the result?
- A. A compilation error occurs at line n1.
- B. A compilation error occurs at line n2.
- C. John Jim
- D. Sam John Jim
Answer: A
NEW QUESTION 32
Given the code fragment:
class CallerThread implements Callable<String> {
String str;
public CallerThread(String s) {this.str=s;}
public String call() throws Exception {
return str.concat("Call");
}
}
and
public static void main (String[] args) throws InterruptedException, ExecutionException
{
ExecutorService es = Executors.newFixedThreadPool(4); //line n1
Future f1 = es.submit (newCallerThread("Call"));
String str = f1.get().toString();
System.out.println(str);
}
Which statement is true?
- A. A compilation error occurs at line n1.
- B. An ExecutionException is thrown at run time.
- C. The program prints Call Call and terminates.
- D. The program prints Call Call and does not terminate.
Answer: D
NEW QUESTION 33
Given the code fragment:
Path source = Paths.get ("/data/december/log.txt");
Path destination = Paths.get("/data");
Files.copy (source, destination);
and assuming that the file /data/december/log.txtis accessible and contains:
10-Dec-2014 - Executed successfully
What is the result?
- A. The program executes successfully and does NOT change the file system.
- B. A FileNotFoundExceptionis thrown at run time.
- C. A file with the name log.txtis created in the /datadirectory and the content of the /data/ december/log.txtfile is copied to it.
- D. A FileAlreadyExistsExceptionis thrown at run time.
Answer: A
NEW QUESTION 34
Given the code fragment:
What is the result?
- A. An ArrayOutOfBoundsException is thrown at runtime.
- B. 1 : 2 : 3 : 4 : 5 :
- C. 1 : 2 : 3 :
- D. Compilation fails.
Answer: B
NEW QUESTION 35
Given:
And given the commands:
javac Test . java
java Test
What is the result?
- A. java SE
- B. Java EE
- C. A NullPointerException is thrown at runtime.
- D. Compilation fails at line n1.
Answer: B
Explanation:
There is no NullPointerException thrown,the value of x is zero, so checkLimit (x) should return
"false".
NEW QUESTION 36
Given the code fragment:
What is the result?
- A. A compilation error occurs at line n1.
- B.
- C. 0
- D. A compilation error occurs at line n2.
3
Answer: D
NEW QUESTION 37
Given:
and the code fragment:
Which definition of the ColorSorterclass sorts the blocks list?
- A.

- B.

- C.

- D.

Answer: B
NEW QUESTION 38
Given the Greetings.propertiesfile, containing:
and given:
What is the result?
- A. Hello, everyone!
- B. GOODBY_MSG
- C. Compilation fails.
- D. HELLO_MSG
- E. Goodbye everyone!
Answer: C
NEW QUESTION 39
Given:
- A. A ClassCastException is thrown at runtime
- B. Ym
Xm1 - C. Compilation fails
- D. Ym
Xm2
Answer: D
NEW QUESTION 40
Given:
class Worker extends Thread {
CyclicBarrier cb;
public Worker(CyclicBarrier cb) { this.cb = cb; }
public void run () {
try {
cb.await();
System.out.println("Worker...");
} catch (Exception ex) { }
}
}
class Master implements Runnable { //line n1
public void run () {
System.out.println("Master...");
}
}
and the code fragment:
Master master = new Master();
//line n2
Worker worker = new Worker(cb);
worker.start();
You have been asked to ensure that the run methods of both the Worker and Master classes are executed.
Which modification meets the requirement?
- A. At line n2, insert CyclicBarrier cb = new CyclicBarrier(2, master);
- B. At line n2, insert CyclicBarrier cb = new CyclicBarrier(1, master);
- C. Replace line n1 with class Master extends Thread {
- D. At line n2, insert CyclicBarrier cb = new CyclicBarrier(master);
Answer: C
NEW QUESTION 41
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 Projectsdirectory exists and contains a list of files.
What is the result?
- A. A compilation error occurs at line n1.
- B. The program prints files names concurrently.
- C. The program prints files names sequentially.
- D. The program throws a runtime exception at line n2.
Answer: B
NEW QUESTION 42
Given the code fragments:
class Employee {
Optional<Address> address;
Employee (Optional<Address> address) {
this.address = address;
}
public Optional<Address> getAddress() { return address; }
}
class Address {
String city = "New York";
public String getCity { return city: }
public String toString() {
return city;
}
}
and
Address address = null;
Optional<Address> addrs1 = Optional.ofNullable (address);
Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not available"; What is the result?
- A. A NoSuchElementException is thrown at run time.
- B. City Not available
- C. null
- D. New York
Answer: C
NEW QUESTION 43
Given:
and the code fragment:
What is the result?
- A. false
true - B. true
false - C. true
true - D. false
false
Answer: B
NEW QUESTION 44
Given the code fragments:
class ThreadRunner implements Runnable {
public void run () { System.out.print ("Runnable") ; }
}
class ThreadCaller implements Callable {
Public String call () throws Exception {return "Callable"; )
}
and
ExecutorService es = Executors.newCachedThreadPool ();
Runnable r1 = new ThreadRunner ();
Callable c1 = new ThreadCaller ();
// line n1
es.shutdown();
Which code fragment can be inserted at line n1to start r1and c1 threads?
Future<String> f1 = (Future<String>) es.submit (r1);
- A. Future<String> f1 = es.execute (c1) ;
Future<String> f1 = (Future<String>) es.execute(r1); - B. Future<String> f1 = es.submit (c1);
- C. Future<String> f2 = (Future<String>) es.execute(c1);
es.submit(r1); - D. es.execute (c1);
es.execute (r1);
Answer: B
NEW QUESTION 45
......
Feel Oracle 1z0-809 Dumps PDF Will likely be The best Option: https://measureup.preppdf.com/Oracle/1z0-809-prepaway-exam-dumps.html