Latest Oracle 1z0-809 Practice Test Questions, Java SE 8 Programmer II Exam Dumps [Q57-Q72]

Share

Latest Oracle 1z0-809 Practice Test Questions, Java SE 8 Programmer II Exam Dumps

Jul-2023 Pass Oracle 1z0-809 Exam in First Attempt Easily

NEW QUESTION # 57
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 n1 to start r1 and c1 threads?

  • A. es.submit(r1);Future<String> f1 = es.submit (c1);
  • B. Future<String> f1 = (Future<String>) es.submit (r1);es.execute (c1);
  • C. Future<String> f1 = (Future<String>) es.execute(r1);Future<String> f2 = (Future<String>) es.execute(c1);
  • D. es.execute (r1);Future<String> f1 = es.execute (c1) ;

Answer: A


NEW QUESTION # 58
Given the code fragment:
List<String> colors = Arrays.asList("red", "green", "yellow");
Predicate<String> test = n - > {
System.out.println("Searching...");
return n.contains("red");
};
colors.stream()
. filter(c -> c.length() > 3)
. allMatch(test);
What is the result?

  • A. Searching...
    Searching...
    Searching...
  • B. A compilation error occurs.
  • C. Searching...
  • D. Searching...
    Searching...

Answer: B


NEW QUESTION # 59
Given the code fragments:

and

What is the result?

  • A. Optional[France]
    Not Found
  • B. France
    Optional[NotFound]
  • C. France
    Not Found
  • D. Optional [France]
    Optional [NotFound]

Answer: C


NEW QUESTION # 60
Given:

What is the result?

  • A. The loop executes infinite times
  • B. The sum is 15
  • C. Compilation fails
  • D. The sum is 14
  • E. The sum is 2

Answer: C


NEW QUESTION # 61
Given the code snippet from a compiled Java source file:

Which command-line arguments should you pass to the program to obtain the following output?
Arg is 2

  • A. java MyFile 2 1 2
  • B. java MyFile 0 1 2 3
  • C. java MyFile 1 3 2 2
  • D. java MyFile 1 2 2 3 4

Answer: C


NEW QUESTION # 62
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 ExecutionExceptionis thrown at run time.
  • C. The program prints Call Calland does not terminate.
  • D. The program prints Call Calland terminates.

Answer: C


NEW QUESTION # 63
Given:

And given the commands:

What is the result?

  • A. Failure
  • B. Compilation fails.
  • C. Success
  • D. An exception is thrown at runtime.

Answer: A


NEW QUESTION # 64
Assume customers.txt is accessible and contains multiple lines.
Which code fragment prints the contents of the customers.txt file?

  • A. Stream<Path> stream = Files.list (Paths.get ("customers.txt"));stream.forEach( c) ->
    System.out.println(c));
  • B. Stream<String> lines = Files.lines (Paths.get ("customers.txt"));lines.forEach( c) ->
    System.out.println(c));
  • C. Stream<String> stream = Files.find (Paths.get ("customers.txt"));stream.forEach((String c) ->
    System.out.println(c));
  • D. Stream<Path> stream = Files.find (Paths.get ("customers.txt"));stream.forEach( c) ->
    System.out.println(c));

Answer: B


NEW QUESTION # 65
Given the code fragment:

Which two modifications should you make so that the code compiles successfully?

  • A. Replace line 5 with public void printFileContent ( ) throws IOException (
  • B. Replace line 11 with public static void main (String [ ] args) throws Exception (
  • C. Replace line 13 with:
  • D. At line 14, insert throw new IOException ( );
  • E. Replace line 7 with throw IOException ("Exception raised");

Answer: A,B


NEW QUESTION # 66
Given:
Book.java:
public class Book {
private String read(String bname) { return "Read" + bname }
}
EBook.java:
public class EBook extends Book {
public class String read (String url) { return "View" + url }
}
Test.java:
public class Test {
public static void main (String[] args) {
Book b1 = new Book();
b1.read("Java Programing");
Book b2 = new EBook();
b2.read("http://ebook.com/ebook");
}
}
What is the result?

  • A. Read Java Programming Read http:/ ebook.com/ebook
  • B. The EBook.java file fails to compile.
  • C. The Test.java file fails to compile.
  • D. Read Java Programming View http:/ ebook.com/ebook

Answer: C


NEW QUESTION # 67
Given the code fragment:
Path file = Paths.get ("courses.txt");
// line n1
Assume the courses.txtis accessible.
Which code fragment can be inserted at line n1to enable the code to print the content of the courses.txtfile?

  • A. List<String> fc = readAllLines(file);
    fc.stream().forEach (s - > System.out.println(s));
  • B. Stream<String> fc = Files.lines (file);
    fc.forEach (s - > System.out.println(s));
  • C. Stream<String> fc = Files.readAllLines (file);
    fc.forEach (s - > System.out.println(s));
  • D. List<String> fc = Files.list(file);
    fc.stream().forEach (s - > System.out.println(s));

Answer: C


NEW QUESTION # 68
Which two statements are true about synchronization and locks? (Choose two.)

  • A. A thread automatically acquires the intrinsic lock on a synchronized statement when executed.
  • B. The intrinsic lock will be retained by a thread if return from a synchronized method is caused by an uncaught exception.
  • C. A thread automatically acquires the intrinsic lock on a synchronized method's object when entering that method.
  • D. A thread exclusively owns the intrinsic lock of an object between the time it acquires the lock and the time it releases it.
  • E. Threads cannot acquire intrinsic locks on classes.

Answer: A,B


NEW QUESTION # 69
Given the code fragment:

Which three lines fail to compile?

  • A. line 10
  • B. line 8
  • C. line 7
  • D. line 11
  • E. line 9
  • F. line 12

Answer: A,C,F


NEW QUESTION # 70
Given the following class:

Which two changes would encapsulate this class and ensure that the area field is always equal to length * height whenever the Rectangle class is used?

  • A. Change the area field to public.
  • B. Call the setArea method at the end of the setLength method.
  • C. Call the setArea method at the beginning of the setHeight method.
  • D. Call the setArea method at the end of the setHeight method.
  • E. Call the setArea method at the beginning of the setLength method.
  • F. Change the setArea method to private.

Answer: A,F


NEW QUESTION # 71
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() > 50; //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. John Jim
  • C. Sam John Jim
  • D. A compilation error occurs at line n2.

Answer: B


NEW QUESTION # 72
......

Free 1z0-809 Exam Files Downloaded Instantly 100% Dumps & Practice Exam: https://www.pass4leader.com/Oracle/1z0-809-exam.html

Updated Verified 1z0-809 dumps Q&As - 100% Pass Guaranteed: https://drive.google.com/open?id=1Ms0PQ4Zw1FXAKRYBvB9QdKGBU8jE-vyI