1z0-809.exam.50q: Website: VCE To PDF Converter: Facebook: Twitter
1z0-809.exam.50q: Website: VCE To PDF Converter: Facebook: Twitter
1z0-809.exam.50q: Website: VCE To PDF Converter: Facebook: Twitter
50q
Number: 1z0-809
Passing Score: 800
Time Limit: 120 min
Website: https://vceplus.com
VCE to PDF Converter: https://vceplus.com/vce-to-pdf/
Facebook: https://www.facebook.com/VCE.For.All.VN/
Twitter : https://twitter.com/VCE_Plus
https://vceplus.com/
1z0-809
Java SE 8 Programmer II
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Exam A
QUESTION 1
Given:
public class Foo<K, V> { private K key; private V value; public Foo (K
key, V value) (this.key = key; this value = value;) public static <T> Foo<T, T>
twice (T value) (return new Foo<T, T> (value, value); )
https://vceplus.com/
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
QUESTION 2
Given the code fragment:
Stream<List<String>> iStr= Stream.of (
Arrays.asList (“1”, “John”),
Arrays.asList (“2”, null)0;
Stream<<String> nInSt = iStr.flatMapToInt ((x) -> x.stream ());
nInSt.forEach (System.out :: print);
A. 1John2null
B. 12
C. A NullPointerException is thrown at run time.
D. A compilation error occurs.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 3
Given the code fragment:
Path file = Paths.get (“courses.txt”);
// line n1
A. List<String> fc = Files.list(file);
fc.stream().forEach (s - > System.out.println(s)); B.
Stream<String> fc = Files.readAllLines (file);
fc.forEach (s - > System.out.println(s)); C.
List<String> fc = readAllLines(file);
fc.stream().forEach (s - > System.out.println(s));
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
D. Stream<String> fc = Files.lines (file); fc.forEach
(s - > System.out.println(s));
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 4
Given the code fragment:
public void recDelete (String dirName) throws IOException {
File [ ] listOfFiles = new File (dirName) .listFiles();
if (listOfFiles ! = null && listOfFiles.length >0) {
for (File aFile : listOfFiles) { if
(aFile.isDirectory ()) {
recDelete (aFile.getAbsolutePath ());
} else {
if (aFile.getName ().endsWith (“.class”))
aFile.delete ();
}
}
}
}
Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is
invoked. What is the result?
A. The method deletes all the .class files in the Projects directory and its subdirectories.
B. The method deletes the .class files of the Projects directory only.
C. The method executes and does not make any changes to the Projects directory.
D. The method throws an IOException.
Correct Answer: A
Section: (none)
Explanation
https://www.gratisexam.com/
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Explanation/Reference:
QUESTION 5
Given the code fragments:
4. void doStuff() throws ArithmeticException, NumberFormatException, Exception
{
5. if (Math.random() >-1 throw new Exception (“Try again”); 6. } and
24. try {
25. doStuff ( ):
26. } catch (ArithmeticException | NumberFormatException | Exception e) {
27. System.out.println (e.getMessage()); } 28. catch (Exception e) {
29. System.out.println (e.getMessage()); }
30. }
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 6
Given the definition of the Country class:
public class country {
public enum Continent {ASIA, EUROPE}
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
String name;
Continent region;
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 7
Given the code fragment:
Map<Integer, String> books = new TreeMap<>();
books.put (1007, “A”); books.put (1002, “C”);
https://www.gratisexam.com/
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
books.put (1001, “B”); books.put (1003, “B”);
System.out.println (books);
https://vceplus.com/
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Reference: TreeMap inherits SortedMap and automatically sorts the element's key
QUESTION 8
Given:
class Book { int id; String
name; public Book (int id, String
name) { this.id = id;
this.name = name;
}
public boolean equals (Object obj) { //line n1
boolean output = false; Book b = (Book) obj;
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
if (this.name.equals(b name))} output = true;
} return output;
}
}
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 9
Given the content of /resourses/Message.properties:
welcome1=”Good day!”
https://www.gratisexam.com/
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
What is the result?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 10
Which action can be used to load a database driver by using JDBC3.0?
A. Add the driver class to the META-INF/services folder of the JAR file.
B. Include the JDBC driver class in a jdbc.properties file.
C. Use the java.lang.Class.forName method to load the driver class.
D. Use the DriverManager.getDriver method to load the driver class.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 11
Given the code fragment:
Path p1 = Paths.get(“/Pics/MyPic.jpeg”);
System.out.println (p1.getNameCount() +
“:” + p1.getName(1) +
“:” + p1.getFileName());
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Assume that the Pics directory does NOT exist.
What is the result?
Explanation/Reference:
QUESTION 12
Given the code fragments:
class MyThread implements Runnable {
private static AtomicInteger count = new AtomicInteger (0);
public void run () { int x = count.incrementAndGet();
System.out.print (x+” “);
}
} and
Correct Answer: A
https://www.gratisexam.com/
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Section: (none)
Explanation
Explanation/Reference:
QUESTION 13
Given the code fragment:
public static void main (String [ ] args) throws IOException {
BufferedReader br = new BufferedReader (new InputStremReader (System.in));
System.out.print (“Enter GDP: “);
//line 1
}
Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 14
Given the code fragment:
Path source = Paths.get (“/data/december/log.txt”);
Path destination = Paths.get(“/data”);
Files.copy (source, destination);
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
A. A file with the name log.txt is created in the /data directory and the content of the /data/december/log.txt file is copied to it.
B. The program executes successfully and does NOT change the file system.
C. A FileNotFoundException is thrown at run time.
D. A FileAlreadyExistsException is thrown at run time.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 15
Given:
class Student { String
course, name, city;
public Student (String name, String course, String city) {
this.course = course; this.name = name; this.city = city;
}
public String toString() { return
course + “:” + name + “:” + city;
}
https://www.gratisexam.com/
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Java ME
C. [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
[Java EE: Helen:Houston]
D. A compilation error occurs.
Correct Answer: B
Section: (none)
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Explanation
Explanation/Reference:
QUESTION 16
Given the code fragments:
interface CourseFilter extends Predicate<String> {
public default boolean test (String str) {
return str.equals (“Java”);
}
} and
A. 2
B. 3
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
QUESTION 17
Given:
public class Emp {
String fName;
String lName;
public Emp (String fn, String ln) {
fName = fn; lName = ln;
}
public String getfName() { return fName; }
public String getlName() { return lName; }
}
Which code fragment, when inserted at line n1, sorts the employees list in descending order of fName and then ascending order of
lName?
A. .sorted
(Comparator.comparing(Emp::getfName).reserved().thenComparing(Emp::getlName))
B. .sorted (Comparator.comparing(Emp::getfName).thenComparing(Emp::getlName))
C. .map(Emp::getfName).sorted(Comparator.reserveOrder())
D. .map(Emp::getfName).sorted(Comparator.reserveOrder().map(Emp::getlName).reserved
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 18
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Given:
public enum USCurrency {
PENNY (1),
NICKLE(5),
DIME (10),
QUARTER(25);
private int value;
https://vceplus.com/
Explanation/Reference:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
QUESTION 19
Correct Answer: BC
Section: (none)
Given:
class ImageScanner implements AutoCloseable {
public void close () throws Exception {
System.out.print (“Scanner closed.”);
}
public void scanImage () throws Exception {
System.out.print (“Scan.”); throw new
Exception(“Unable to scan.”);
} } class ImagePrinter implements
AutoCloseable { public void close ()
throws Exception { System.out.print
(“Printer closed.”);
}
public void printImage () {System.out.print(“Print.”); }
}
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 20
Given the structure of the STUDENT table:
Given:
public class Test {
static Connection newConnection =null;
public static Connection get DBConnection () throws SQLException { try
(Connection con = DriveManager.getConnection(URL, username, password)) {
newConnection = con;
}
return newConnection;
}
public static void main (String [] args) throws SQLException {
get DBConnection ();
Statement st = newConnection.createStatement();
st.executeUpdate(“INSERT INTO student VALUES (102, ‘Kelvin’)”);
}
}
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the URL, userName, and passWord exists.
The SQL query is valid.
A. The program executes successfully and the STUDENT table is updated with one record.
B. The program executes successfully and the STUDENT table is NOT updated with any record.
C. A SQLException is thrown as runtime.
Explanation
Explanation/Reference:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
QUESTION 21
Correct Answer: C
Section: (none)
Given the code fragments:
class Employee {
Optional<Address> address;
Employee (Optional<Address> address) {
this.address = address;
} public Optional<Address> getAddress() { return address;
}
}
A. New York
B. City Not available
C. null
D. A NoSuchElementException is thrown at run time.
Correct Answer: B
Section: (none)
Explanation
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Explanation/Reference:
Explanation
Explanation/Reference:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
QUESTION 22
Given the definition of the Vehicle class:
class Vehicle { String name;
void setName (String name) {
this.name = name; }
String getName() {
return name;
}
}
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 23
Given:
public class product { int id; int
price; public Product (int id, int
price) { this.id = id;
this.price = price;
}
public String toString() { return id + “:” + price; }
}
and the code fragment:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
List<Product> products = Arrays.asList(new Product(1, 10),
new Product (2, 30), new Product (2, 30));
Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> {
p1.price+=p2.price; return new Product (p1.id, p1.price);});
products.add(p); products.stream().parallel()
.reduce((p1, p2) - > p1.price > p2.price ? p1 : p2)
.ifPresent(System.out: :println);
A. 2 : 30
B. 4 : 0
C. 4 : 60
D. 4 : 60
2 : 30
3 : 20
1 : 10
E. The program prints nothing.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 24
Given the code fragments:
public class Book implements Comparator<Book> {
String name; double price; public Book
() {}
public Book(String name, double price) {
this.name = name; this.price = price;
}
public int compare(Book b1, Book b2) {
return b1.name.compareTo(b2.name);
}
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
public String toString() {
return name + “:” + price; } }
and
List<Book>books = Arrays.asList (new Book (“Beginning with Java”, 2), new book (“A
Guide to Java Tour”, 3));
Collections.sort(books, new Book());
System.out.print(books);
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 25
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?
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 26
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
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Run Runner
Call Caller : Run
C. A compilation error occurs at line n1.
D. An Execution is thrown at run time.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 27
Given:
public class Canvas implements Drawable {
public void draw () { }
} public abstract class Board extends Canvas {
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
https://vceplus.com/
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 28
Given the code fragment:
List<String> str = Arrays.asList (“my”, “pen”, “is”, “your’, “pen”);
Predicate<String> test = s -> {
int i = 0;
boolean result = s.contains (“pen”);
System.out.print(i++) + “:”); return
result;
}; str.stream()
.filter(test)
.findFirst()
.ifPresent(System.out ::print);
A. 0 : 0 : pen
B. 0 : 1 : pen C. 0 : 0 : 0 : 0 : 0 : pen
D. 0 : 1 : 2 : 3 : 4 :
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
E. A compilation error occurs.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 29
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
A. 100, Robin, HR
101, Peter, HR
B. 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
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 30
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Given:
interface Rideable {Car getCar (String name); }
class Car {
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 31
Which statement is true about the single abstract method of the java.util.function.Function interface?
Correct Answer: D
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Section: (none)
Explanation
Explanation/Reference:
QUESTION 32
Which statement is true about the DriverManager class?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
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
QUESTION 33
Given the code fragment:
List<Integer> nums = Arrays.asList (10, 20, 8):
System.out.println (
//line n1
);
Which code fragment must be inserted at line n1 to enable the code to print the maximum number in the nums list?
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 34
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() {} }
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
QUESTION 35
Which two statements are true about localizing an application?
A. Support for new regional languages does not require recompilation of the code.
B. Textual elements (messages and GUI labels) are hard-coded in the code.
C. Language and region-specific programs are created using localized data.
D. Resource bundle files include data and currency information.
E. Language codes use lowercase letters and region codes use uppercase letters.
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
Reference: http://docs.oracle.com/javase/7/docs/technotes/guides/intl/
QUESTION 36
Which statement is true about java.util.stream.Stream?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 37
Given:
class Worker extends Thread {
CyclicBarrier cb;
public Worker(CyclicBarrier cb) { this.cb = cb; }
public void run () { try { cb.await();
System.out.println(“Worker…”);
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
} 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?
https://vceplus.com/
Correct Answer: C
Section: (none)
Explanation
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Explanation/Reference:
QUESTION 38
Given the code fragment:
String str = “Java is a programming language”;
ToIntFunction<String> indexVal = str: : indexOf; //line n1
int x = indexVal.applyAsInt(“Java”); //line n2
System.out.println(x);
A. 0
B. 1
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 39
Given the code fragment:
List<String> codes = Arrays.asList (“DOC”, “MPEG”, “JPEG”);
codes.forEach (c -> System.out.print(c + “ “));
String fmt = codes.stream()
.filter (s-> s.contains (“PEG”))
.reduce((s, t) -> s + t).get();
System.out.println(“\n” + fmt);
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
B. DOC MPEG MPEGJPEG MPEGMPEGJPEG
C. MPEGJPEG
MPEGJPEG
D. The order of the output is unpredictable.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 40
Given the code fragment:
List<String> nL = Arrays.asList(“Jim”, “John”, “Jeff”);
Function<String, String> funVal = s -> “Hello : “.contact(s);
nL.Stream() .map(funVal)
.peek(System.out::print);
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 41
Given:
public interface Moveable<Integer> {
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
public default void walk (Integer distance) {System.out.println(“Walking”);)
public void run(Integer distance); }
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 42
Which two code blocks correctly initialize a Locale variable?
Correct Answer: DE
Section: (none)
Explanation
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Explanation/Reference:
QUESTION 43
Given the code fragment:
BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; //line n1
System.out.println(val.apply(10, 10.5));
A. 20
B. 20.5
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 44
Which statement is true about java.time.Duration?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Reference: http://tutorials.jenkov.com/java-date-time/duration.html#accessing-the-time-of-a-duration
QUESTION 45
Given the code fragment:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
UnaryOperator<Integer> uo1 = s -> s*2; line n1
List<Double> loanValues = Arrays.asList(1000.0, 2000.0);
loanValues.stream() .filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + “ “));
A. 4000.0
B. 4000
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 46
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
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Which statement is true?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 47
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
}
}
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 48
Given:
class CheckClass {
public static int checkValue (String s1, String s2) {
return s1 length() – s2.length();
}
}
Which code fragment should be inserted at line n1 to enable the code to print Rat Cat Lion Tiger?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 49
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Given the code fragments:
class TechName {
String techName;
TechName (String techName) {
this.techName=techName;
}
} and
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);
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 50
Given that /green.txt and /colors/yellow.txt are accessible, and the code fragment:
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online
Which statement is true?
A. The green.txt file content is replaced by the yellow.txt file content and the yellow.txt file is deleted.
B. The yellow.txt file content is replaced by the green.txt file content and an exception is thrown.
C. The file green.txt is moved to the /colors directory.
D. A FileAlreadyExistsException is thrown at runtime.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
https://vceplus.com/
www.vceplus.com - VCE Exam Simulator - Download A+ VCE (latest) free Open VCE Exams - VCE to PDF Converter - PDF Online