Pass the Oracle Java SE 1z0-809 Questions and answers with CertsForce

Viewing page 2 out of 7 pages
Viewing questions 11-20 out of questions
Questions # 11:

Given the code fragment:

UnaryOperator uo1 = s -> s*2;line n1

List loanValues = Arrays.asList(1000.0, 2000.0);

loanValues.stream()

.filter(lv -> lv >= 1500)

.map(lv -> uo1.apply(lv))

.forEach(s -> System.out.print(s + “ “));

What is the result?

Options:

A.

4000.0


B.

4000


C.

A compilation error occurs at line n1.


D.

A compilation error occurs at line n2.


Expert Solution
Questions # 12:

Given the code fragment:

Question # 12

What is the result?

Options:

A.

A compilation error occurs.


B.

[Java, J2EE, J2ME, JSTL, JSP]


C.

null


D.

[Java, J2EE, J2ME, JSTL]


Expert Solution
Questions # 13:

Given the code fragment:

Question # 13

Which code fragment, when inserted at line 7, enables printing 100?

Options:

A.

Function funRef = e –> e + 10;Integer result = funRef.apply(value);


B.

IntFunction funRef = e –> e + 10;Integer result = funRef.apply (10);


C.

ToIntFunction funRef = e –> e + 10;int result = funRef.applyAsInt (value);


D.

ToIntFunction funRef = e –> e + 10;int result = funRef.apply (value);


Expert Solution
Questions # 14:

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. }

Which modification enables the code to print Try again?

Options:

A.

Comment the lines 28, 29 and 30.


B.

Replace line 26 with:} catch (Exception | ArithmeticException | NumberFormatException e) {


C.

Replace line 26 with:} catch (ArithmeticException | NumberFormatException e) {


D.

Replace line 27 with:throw e;


Expert Solution
Questions # 15:

Given the code fragments:

Question # 15

and

Question # 15

What is the result?

Options:

A.

The program prints Run… and throws an exception.


B.

A compilation error occurs at line n1.


C.

Run…Call…


D.

A compilation error occurs at line n2.


Expert Solution
Questions # 16:

Which code fragment is required to load a JDBC 3.0 driver?

Options:

A.

Connection con = Connection.getDriver(“jdbc:xyzdata://localhost:3306/EmployeeDB”);


B.

Class.forName(“org.xyzdata.jdbc.NetworkDriver”);


C.

Connection con = DriverManager.getConnection(“jdbc:xyzdata://localhost:3306/EmployeeDB”);


D.

DriverManager.loadDriver (“org.xyzdata.jdbc.NetworkDriver”);


Expert Solution
Questions # 17:

Given the code fragment:

public class Foo {

public static void main (String [ ] args) {

Map unsortMap = new HashMap< > ( );

unsortMap.put (10, “z”);

unsortMap.put (5, “b”);

unsortMap.put (1, “d”);

unsortMap.put (7, “e”);

unsortMap.put (50, “j”);

Map treeMap = new TreeMap (new

Comparator ( ) {

@Override public int compare (Integer o1, Integer o2) {return o2.compareTo

(o2); } } );

treeMap.putAll (unsortMap);

for (Map.Entry entry : treeMap.entrySet () ) {

System.out.print (entry.getValue () + “ “);

}

}

}

What is the result?

Options:

A.

A compilation error occurs.


B.

d b e z j


C.

j z e b d


D.

z b d e j


Expert Solution
Questions # 18:

Given the structure of the STUDENT table:

Student (id INTEGER, name VARCHAR)

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.

What is the result?

Options:

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.


Expert Solution
Questions # 19:

Given the code fragment:

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

LocalDate next15days = valentinesDay.plusDays (15);

LocalDate nextYear = next15days.plusYears(1); // line n1

System.out.println(nextYear);

What is the result?

Options:

A.

2016-03-01


B.

A DateTimeException is thrown.


C.

2016-02-29


D.

A compilation error occurs at line n1.


Expert Solution
Questions # 20:

Given that version.txt is accessible and contains:

1234567890

and given the code fragment:

Question # 20

What is the result?

Options:

A.

121


B.

122


C.

135


D.

The program prints nothing.


Expert Solution
Viewing page 2 out of 7 pages
Viewing questions 11-20 out of questions