Ensurepass
2017 July Oracle Official New Released 1Z0-809 Q&As
100% Free Download! 100% Pass Guaranteed!
http://www.ensurepass.com/1Z0-809.html

Java SE 8 Programmer II

QUESTION 31

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?

 

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: D

 

 

QUESTION 32

public class StringReplace {

 

public static void main(String[] args) {

 

String message = “Hi everyone!”;

 

System.out.println(“message = ” + message.replace(“e”, “X”)); }

 

}

 

What is the result?

 

A.

message = Hi everyone!

B.

message = Hi XvXryonX!

C.

A compile time error is produced.

D.

A runtime error is produced.

E.

message =

F.

message = Hi Xveryone!

 

Correct Answer: B

 

 

QUESTION 33

Given the code fragment:

 

Path p1 = Paths.get(“/Pics/MyPic.jpeg”);

 

System.out.println (p1.getNameCount() +

 

“:” + p1.getName(1) +

 

“:” + p1.getFileName());

 

Assume that the Pics directory does NOT exist.

 

What is the result?

 

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: C

 

 

QUESTION 34

Given the definition of the Country class:

 

public class country {

 

public enum Continent {ASIA, EUROPE}

 

< span lang="EN-US" style="font-family: ; mso-font-kerning: 0pt; mso-no-proof: yes">String name;

 

Continent region;

 

public Country (String na, Continent reg) {

 

name = na, region = reg;

 

}

 

public String getName () {return name;}

 

public Continent getRegion () {return region;}

 

}

 

and the code fragment:

 

List<Country> couList = Arrays.asList (

 

new Country (“Japan”, Country.Continent.ASIA),

 

new Country (“Italy”, Country.Continent.EUROPE),

 

new Country (“Germany”, Country.Continent.EUROPE));

 

Map<Country.Continent, List<String>> regionNames = couList.stream ()

 

.collect(Collectors.groupingBy (Country ::getRegion,

 

Collectors.mapping(Country::getName, Collectors.toList()))));

 

System.out.println(regionNames);

 

What is the output?

 

A.

{EUROPE = [Italy, Germany], ASIA = [Japan]}

B.

{ASIA = [Japan], EUROPE = [Italy, Germany]}

C.

{EUROPE = [Germany, Italy], ASIA = [Japan]}

D.

{EUROPE = [Germany], EUROPE = [Italy], ASIA = [Japan]}

 

Correct Answer: A

 

 

QUESTION 35

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);

 

What is the result?

 

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: E

 

 

QUESTION 36

The protected modifier on a Field declaration within a public class means that the field ______________.

 

A.

Cannot be modified

B.

Can be read but not written from outside the class

C.

Can be read and written from this class and its subclasses only within the same package

D.

< font face="Arial">Can be read and written from this class and its subclasses defined in any package

 

Correct Answer: D

Explanation:

http://beginnersbook.com/2013/05/java-access-modifiers/

 

 

QUESTION 37

A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the results?

 

A.

Compilation fails.

B.

The third argument is given the value null.

C.

The third argument is given the value void.

D.

The third argument is given the value zero.

E.

The third argument is given the appropriate falsy value for its declared type. F) An exception occurs when the method attempts to access the third argument.

 

Correct Answer: A

 

 

QUESTION 38

Which statement is true about the single abstract method of the java.util.function.Function interface?

 

A.

It accepts one argument and returns void.

B.

It accepts one argument and returns boolean.

C.

It accepts one argument and always produces a result of the same type as the argument.

D.

It accepts an argument and produces a result of any data type.

 

Correct Answer: C

Explanation:

http://winterbe.com/posts/2014/03/16/java-8-tutorial/ (functions)

QUESTION 39

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() {}

 

}

 

Which statement is true?

 

A.

A compilation error occurs in IceCream.

B.

A compilation error occurs in Cake.

C.

A compilation error occurs in Shop.

D.

A compilation error occurs in Bread

E.

All classes compile successfully.

 

Correct Answer: D

 

 

QUESTION 40

Given:

 

clip_image002

 

What is the result?

 

A.

Marrown

String out of limits

JesOran

B.

Marrown

String out of limits

Array out of limits

C.

Marrown

String out of limits

D.

Marrown

NanRed

JesOran

 

Correct Answer: A

100% Free Download!
—Download Free Demo:1Z0-809 Demo PDF
100% Pass Guaranteed!
Download 2017 Ensurepass 1Z0-809 Full Exam PDF and VCE Q&As:128
—Get 10% off your purchase! Copy it:TJDN-947R-9CCD [2017.07.01-2017.07.31]

Ensurepass ExamCollection Testking
Lowest Price Guarantee Yes No No
Up-to-Dated Yes No No
Real Questions Yes No No
Explanation Yes No No
PDF + VCE Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

2017 Ensurepass IT Certification PDF and VCE