Number: 1z0-809 Passing Score: 800 Time Limit: 120 Min
Number: 1z0-809 Passing Score: 800 Time Limit: 120 Min
96q
Number: 1z0-809
Passing Score: 800
Time Limit: 120 min
1z0-809
https://www.gratisexam.com/
Java SE 8 Programmer II
https://www.gratisexam.com/
Exam A
QUESTION 1
Given:
https://www.gratisexam.com/
https://www.gratisexam.com/
and given that the sum of all integers from 1 to 10 is 55.
Which statement is true?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 2
Given the content of Operator.java, EngineOperator.java, and Engine.java files:
https://www.gratisexam.com/
and the code fragment:
Correct Answer: A
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 3
Given the code fragment:
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 4
Given the code fragment:
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));
https://www.gratisexam.com/
C. List<String> fc = readAllLines(file);
fc.stream().forEach (s - > System.out.println(s));
D. Stream<String> fc = Files.lines (file);
fc.forEach (s - > System.out.println(s));
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 5
Given the code fragment:
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/
Explanation/Reference:
QUESTION 6
Given the definition of the Country class:
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 7
Given the code fragment:
https://www.gratisexam.com/
Map<Integer, String> books = new TreeMap<>();
books.put (1007, “A”);
books.put (1002, “C”);
books.put (1001, “B”);
books.put (1003, “B”);
System.out.println (books);
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;
if (this.name.equals(b name))}
output = true;
}
return output;
}
}
https://www.gratisexam.com/
and the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 9
Given the content of /resourses/Message.properties:
welcome1=”Good day!”
A. Good day!
Test
followed by an Exception stack trace
https://www.gratisexam.com/
B. Good day!
followed by an Exception stack trace
C. Good day!
Test
null
D. A compilation error occurs at line n1.
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());
https://www.gratisexam.com/
A. An exception is thrown at run time.
B. 2:MyPic.jpeg: MyPic.jpeg
C. 1:Pics:/Pics/ MyPic.jpeg
D. 2:Pics: MyPic.jpeg
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 12
Given the code fragments:
and
https://www.gratisexam.com/
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 13
Given:
Which two modifications enable the given code to compile? (Choose two.)
Correct Answer: BC
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 14
Given:
Correct Answer: A
Section: (none)
https://www.gratisexam.com/
Explanation
Explanation/Reference:
QUESTION 15
Given the structure of the STUDENT table:
Given:
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.
D. A NullPointerException is thrown as runtime.
Correct Answer: C
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 16
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
A. New York
B. City Not available
C. null
D. A NoSuchElementException is thrown at run time.
Correct Answer: B
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 17
Given the code fragment:
});
A. All files and directories under the home directory are listed along with their attributes.
B. A compilation error occurs at line n1.
C. The files in the home directory are listed along with their attributes.
D. A compilation error occurs at line n2.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 18
Given that course.txt is accessible and contains:
Course : : Java
https://www.gratisexam.com/
char c;
try (FileInputStream fis = new FileInputStream (“course.txt”);
InputStreamReader isr = new InputStreamReader(fis);) {
while (isr.ready()) { //line n1
isr.skip(2);
i = isr.read ();
c = (char) i;
System.out.print(c);
}
} catch (Exception e) {
e.printStackTrace();
}
}
A. ur :: va
B. ueJa
C. The program prints nothing.
D. A compilation error occurs at line n1.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 19
Given:
https://www.gratisexam.com/
type.set(“Java”);
type1.set(100); //line n2
System.out.print(type.get() + “ “ + type1.get());
}
https://www.gratisexam.com/
}
A. Java 100
B. java.lang.string@<hashcode>java.lang.Integer@<hashcode>
C. A compilation error occurs. To rectify it, replace line n1 with:
Test<Integer> type1 = new Test<>();
D. A compilation error occurs. To rectify it, replace line n2 with:
type1.set (Integer(100));
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 20
Given the definition of the Vehicle class:
class Vehicle {
String name;
void setName (String name) {
this.name = name;
}
String getName() {
return name;
}
}
https://www.gratisexam.com/
Which action encapsulates the Vehicle class?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 21
Given:
https://www.gratisexam.com/
What is the result?
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 22
Given the code fragments:
and
List<Book>books = Arrays.asList (new Book (“Beginning with Java”, 2), new book (“A
Guide to Java Tour”, 3));
https://www.gratisexam.com/
Collections.sort(books, new Book());
System.out.print(books);
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 23
Given the code fragment:
Which code fragment, when inserted at line n1, enables the code to print the count of string elements whose length is greater than three?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 24
https://www.gratisexam.com/
Given the code fragments:
and
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 25
Given:
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 26
Given the code fragment:
https://www.gratisexam.com/
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 :
E. A compilation error occurs.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 27
Given the code fragment:
A. 100, Robin, HR
101, Peter, HR
B. A compilation error occurs at line n1.
C. 100, Robin, HR
https://www.gratisexam.com/
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 28
Which two statements are true about localizing an application? (Choose two.)
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 29
Which statement is true about java.util.stream.Stream?
Correct Answer: B
https://www.gratisexam.com/
Section: (none)
Explanation
Explanation/Reference:
QUESTION 30
The data.doc, data.txt and data.xml files are accessible and contain text.
Given the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 31
Given:
Which two modifications enable the code to print Open Close? (Choose two.)
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 32
You want to create a singleton class by using the Singleton design pattern.
Which two statements enforce the singleton nature of the design? (Choose two.)
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
QUESTION 33
Given the code fragment:
A. 20.0
30.0
B. 10
20
C. A compilation error occurs.
D. A NumberFormatException is thrown at run time.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 34
Given:
A. 0
B. 2
C. 3
D. 4
E. 5
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 35
Given:
Item table
• ID, INTEGER: PK
• DESCRIP, VARCHAR(100)
• PRICE, REAL
• QUANTITY< INTEGER
9. try {
10. Connection conn = DriveManager.getConnection(dbURL, username, password);
11. String query = “Select * FROM Item WHERE ID = 110”;
12. Statement stmt = conn.createStatement();
13. ResultSet rs = stmt.executeQuery(query);
14. while(rs.next()) {
15. System.out.println(“ID: “ + rs.getInt(“Id”));
16. System.out.println(“Description: “ + rs.getString(“Descrip”));
17. System.out.println(“Price: “ + rs.getDouble(“Price”));
18. System.out.println(Quantity: “ + rs.getInt(“Quantity”));
19. }
20. } catch (SQLException se) {
21. System.out.println(“Error”);
22. }
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
The SQL query is valid.
Correct Answer: D
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 36
Given:
You have been asked to ensure that the run methods of both the Worker and Master classes are executed.
Which modification meets the requirement?
Correct Answer: C
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 37
Given the code fragment:
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 38
Given the code fragment:
https://www.gratisexam.com/
C. MPEGJPEG
MPEGJPEG
D. The order of the output is unpredictable.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 39
Given the code fragment:
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 40
Given:
https://www.gratisexam.com/
Which statement is true?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 41
Which two code blocks correctly initialize a Locale variable? (Choose two.)
Correct Answer: DE
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 42
Given:
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 43
Given the definition of the Emp class:
https://www.gratisexam.com/
private Integer eAge;
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 + “ “));
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 44
For which three objects must a vendor provide implementations in its JDBC driver? (Choose three.)
A. Time
B. Date
C. Statement
D. ResultSet
E. Connection
https://www.gratisexam.com/
F. SQLException
G. DriverManager
Explanation/Reference:
Explanation:
Database vendors support JDBC through the JDBC driver interface or through the ODBC connection. Each driver must provide implementations of
java.sql.Connection, java.sql.Statement, java.sql.PreparedStatement, java.sql.CallableStatement, and java.sql.Re sultSet. They must also implement the
java.sql.Driver interface for use by the generic java.sql.DriverManager interface.
QUESTION 45
Given the code fragment:
A. 2016-02-14
B. A DateTimeException is thrown.
C. 2016-02-29
D. A compilation error occurs at line n1.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 46
Given:
interface Doable {
public void doSomething (String s);
https://www.gratisexam.com/
}
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 47
Given the code fragment:
A. Stream.of(list1, list2)
.flatMap(list -> list.stream())
https://www.gratisexam.com/
.forEach(s -> System.out.print(s + “ “));
B. Stream.of(list1, list2)
.flatMap(list -> list.intStream())
.forEach(s -> System.out.print(s + “ “));
C. list1.stream()
.flatMap(list2.stream().flatMap(e1 -> e1.stream())
.forEach(s -> System.out.println(s + “ “));
D. Stream.of(list1, list2)
.flatMapToInt(list -> list.stream())
.forEach(s -> System.out.print(s + “ “));
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 48
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”);
}
}
https://www.gratisexam.com/
A. Read Java Programming
View http:/ ebook.com/ebook
B. Read Java Programming
Read http:/ ebook.com/ebook
C. The EBook.java file fails to compile.
D. The Test.java file fails to compile.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 49
Given the code fragment:
https://www.gratisexam.com/
Correct Answer: A
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 50
Given the code fragment:
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
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 51
Given the code fragment:
https://www.gratisexam.com/
What is the result?
A. Searching...
B. Searching...
Searching...
C. Searching...
Searching...
Searching...
D. A compilation error occurs.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 52
Given:
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 {
https://www.gratisexam.com/
}
A. User is registered.
B. An AgeOutOfLimitException is thrown.
C. A UserException is thrown.
D. A compilation error occurs in the main method.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 53
Given the code fragment:
A. 5 : 3 : 6
B. 6 : 5 : 6
C. 3 : 3 : 4
D. 4 : 4 : 4
Correct Answer: D
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 54
Given:
https://www.gratisexam.com/
A. Implement Predicate in the Product.ProductFilter class and replace line n2 with .filter (p -> p.ProductFilter.test (p))
B. Replace line n1 with:
public static boolean isAvailable (Product p) {
C. Replace line n2 with:
.filter (p -> p.ProductFilter: :isAvailable (p))
D. Replace line n2 with:
.filter (p -> Product: :ProductFilter: :isAvailable ())
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 55
Given the content:
https://www.gratisexam.com/
What is the result?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 56
Given:
https://www.gratisexam.com/
What is the result?
A. –catch-
-finally-
-dostuff-
B. –catch-
C. –finally-
-catch-
D. –finally
-dostuff-
-catch-
Correct Answer: C
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
Explanation:
https://www.gratisexam.com/
https://www.gratisexam.com/
QUESTION 57
Given:
A. Bar Hello
Foo Hello
B. Bar Hello
Baz Hello
https://www.gratisexam.com/
C. Baz Hello
D. A compilation error occurs in the Daze class.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 58
Given the content of the employee.txt file:
Every worker is a master.
Given that the employee.txt file is accessible and the file allemp.txt does NOT exist, and the code fragment:
A. Exception 1
B. Exception 2
C. The program executes, does NOT affect the system, and produces NO output.
D. allemp.txt is created and the content of employee.txt is copied to it.
Correct Answer: A
Section: (none)
https://www.gratisexam.com/
Explanation
Explanation/Reference:
QUESTION 59
Given:
A. IT:null
B. A NullPointerException is thrown at run time.
C. A compilation error occurs.
D. IT:0.0
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 60
Given the code fragment:
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 61
Given:
https://www.gratisexam.com/
What is the result?
A. true
true
B. false
true
C. false
false
D. true
false
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 62
Given:
https://www.gratisexam.com/
What is the result?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 63
Given the code fragment:
Assume that:
https://www.gratisexam.com/
What is the result?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 64
Given the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 65
https://www.gratisexam.com/
and the code fragment?
A. $15.00
B. 15 $
C. USD 15.00
D. USD $15
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 66
Given the code fragment:
https://www.gratisexam.com/
A. text1text2
B. text1text2text2text3
C. text1
D. [text1, text2]
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 67
Given:
and
Which interface from the java.util.function package should you use to refactor the class Txt?
A. Consumer
B. Predicate
https://www.gratisexam.com/
C. Supplier
D. Function
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html
QUESTION 68
Given:
java Product 0
A. An AssertionError is thrown.
B. A compilation error occurs at line n1.
C. New Price: 0.0
D. A NumberFormatException is thrown at run time.
Correct Answer: C
Section: (none)
https://www.gratisexam.com/
Explanation
Explanation/Reference:
QUESTION 69
Given the code fragment:
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 70
Given the code fragments:
https://www.gratisexam.com/
and
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 71
Which two are elements of a singleton class? (Choose two.)
https://www.gratisexam.com/
C. a public static method to return a copy of the singleton reference
D. a private constructor to the class
E. a public reference to point to the single instance
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
QUESTION 72
Given the code fragment:
A. David
David
[Susan, Allen]
B. Susan
Susan
[Susan, Allen]
C. Susan
Allen
[David]
D. David
Allen
[Susan]
E. Susan
Allen
https://www.gratisexam.com/
[Susan, David]
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
https://www.gratisexam.com/
https://www.gratisexam.com/
QUESTION 73
Given:
Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?
https://www.gratisexam.com/
Correct Answer: DE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 74
Given the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 75
Given the code fragment:
https://www.gratisexam.com/
What is the result?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 76
Given the code fragment:
You have been asked to define the ProductCode class. The definition of the ProductCode class must allow c1 instantiation to succeed and cause a compilation
https://www.gratisexam.com/
error on c2 instantiation.
A.
B.
C.
D.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 77
Given the code fragment:
https://www.gratisexam.com/
Which statement can be inserted into line n1 to print 1,2; 1,10; 2,20;?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Reference: https://www.concretepage.com/java/jdk-8/java-8-biconsumer-bifunction-bipredicate-example
QUESTION 78
Given the code fragment:
Correct Answer: D
Section: (none)
Explanation
https://www.gratisexam.com/
Explanation/Reference:
QUESTION 79
Given the code fragments :
and
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 80
Given:
Which two interfaces can you use to create lambda expressions? (Choose two.)
A. T
B. R
C. P
D. S
E. Q
F. U
Correct Answer: CD
Section: (none)
Explanation
Explanation/Reference:
QUESTION 81
Given the code fragment:
https://www.gratisexam.com/
What is the result ?
A. [X]
[X, X]
[X, X, X]
[X, X, X, X]
B. [X, X]
C. [X]
[X, X]
[X, X, X]
D. [X, X]
[X, X, X, X]
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
QUESTION 82
Given that these files exist and are accessible:
Which code fragment can be inserted at line n1 to enable the code to print only /company/emp?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 83
Given:
https://www.gratisexam.com/
and the code fragment:
A. 0
B. A compilation error occurs at line n1.
C. An Exception is thrown at run time.
D. 2
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 84
Which class definition compiles?
https://www.gratisexam.com/
A.
B.
C.
D.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 85
Given the code fragment:
https://www.gratisexam.com/
What is the result?
A. 4000 : 2000
B. 4000 : 1000
C. 1000 : 4000
D. 1000 : 2000
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 86
Given that version.txt is accessible and contains:
1234567890
https://www.gratisexam.com/
What is the result?
A. 121
B. 122
C. 135
D. The program prints nothing.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 87
https://www.gratisexam.com/
What is the result?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 88
Given the Greetings.properties file, containing:
and given:
https://www.gratisexam.com/
What is the result?
A. Compilation fails.
B. GOODBY_MSG
C. Hello, everyone!
D. Goodbye everyone!
E. HELLO_MSG
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 89
Given the code fragments:
https://www.gratisexam.com/
and
A. null
B. A compilation error occurs.
C. DogCatMouse
D. [Dog, Cat, Mouse]
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 90
Given the records from the STUDENT table:
https://www.gratisexam.com/
Given the code fragment:
https://www.gratisexam.com/
113 : Jannet : jannet@uni.com
D. A SQLException is thrown at run time.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 91
Which two statements are true about the Fork/Join Framework? (Choose two.)
A. The RecursiveTask subclass is used when a task does not need to return a result.
B. The Fork/Join framework can help you take advantage of multicore hardware.
C. The Fork/Join framework implements a work-stealing algorithm.
D. The Fork/Join solution when run on multicore hardware always performs faster than standard sequential solution.
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
Reference: https://www.logicbig.com/tutorials/core-java-tutorial/java-multi-threading/fork-and-join.html
QUESTION 92
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 exclusively owns the intrinsic lock of an object between the time it acquires the lock and the time it releases it.
D. A thread automatically acquires the intrinsic lock on a synchronized method’s object when entering that method.
E. Threads cannot acquire intrinsic locks on classes.
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
Reference: https://docs.oracle.com/javase/tutorial/essential/concurrency/locksync.html
QUESTION 93
Given the code fragment:
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 94
Given:
https://www.gratisexam.com/
and the code fragment:
Correct Answer: D
Section: (none)
https://www.gratisexam.com/
Explanation
Explanation/Reference:
Explanation:
https://www.gratisexam.com/
https://www.gratisexam.com/
QUESTION 95
Given the definition of the Employee class:
https://www.gratisexam.com/
B. [Ada:sales, Bob:sales, Bob:hr, Eva:hr]
C. [hr:Eva, hr:Bob, sales:Bob, sales:Ada]
D. [hr:Bob, hr:Eva, sales:Ada, sales:Bob]
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 96
Given the code fragments:
and
Correct Answer: D
https://www.gratisexam.com/
Section: (none)
Explanation
Explanation/Reference:
https://www.gratisexam.com/
https://www.gratisexam.com/