Vcehome > Oracle > Oracle Database > 1Z0-809 > 1Z0-809 Online Practice Questions and Answers

1Z0-809 Online Practice Questions and Answers

Questions 4

Given the code fragments:

class Employee { Optional

address;

Employee (Optional

address) {

this.address = address;

}

public Optional

getAddress() { return address; }

}

class Address {

String city = "New York";

public String getCity { return city: }

public String toString() {

return city;

}

}

and

Address address = null;

Optional

addrs1 = Optional.ofNullable (address);

Employee e1 = new Employee (addrs1);

String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not

available";

What is the result?

A. New York

B. City Not available

C. null

D. A NoSuchElementException is thrown at run time.

Browse 207 Q&As
Questions 5

Given that course.txt is accessible and contains:

Course : : Java

and given the code fragment:

public static void main (String[ ] args) { int i; 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(); } }

What is the result?

A. ur :: va

B. ueJa

C. The program prints nothing.

D. A compilation error occurs at line n1.

Browse 207 Q&As
Questions 6

Given:

public class Canvas implements Drawable {

public void draw () { }

}

public abstract class Board extends Canvas { }

public class Paper extends Canvas {

protected void draw (int color) { }

}

public class Frame extends Canvas implements Drawable {

public void resize () { }

}

public interface Drawable {

public abstract void draw ();

}

Which statement is true?

A. Board does not compile.

B. Paper does not compile.

C. Frame does not compile.

D. Drawable does not compile.

E. All classes compile successfully.

Browse 207 Q&As
Questions 7

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.

Browse 207 Q&As
Questions 8

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

F. SQLException

G. DriverManager

Browse 207 Q&As
Questions 9

Given:

interface Doable {

public void doSomething (String s);

}

Which two class definitions compile? (Choose two.)

A. public abstract class Task implements Doable { public void doSomethingElse(String s) { } }

B. public abstract class Work implements Doable { public abstract void doSomething(String s) { } public void doYourThing(Boolean b) { } }

C. public class Job implements Doable {

public void doSomething(Integer i) { }

}

D. public class Action implements Doable { public void doSomething(Integer i) { } public String doThis(Integer j) { } }

E. public class Do implements Doable { public void doSomething(Integer i) { } public void doSomething(String s) { } public void doThat (String s) { } }

Browse 207 Q&As
Questions 10

Given that these files exist and are accessible:

and given the code fragment:

Which code fragment can be inserted at line n1 to enable the code to print only /company/emp?

A. Stream stream = Files.list (Paths.get ("/company"));

B. Stream stream = Files.find( Paths.get (“/company”), 1, (p,b) –andgt; b.isDirectory (), FileVisitOption.FOLLOW_LINKS);

C. Stream stream = Files.walk (Paths.get ("/company"));

D. Stream stream = Files.list (Paths.get ("/company/emp"));

Browse 207 Q&As
Questions 11

What is the result?

A. A compilation error occurs at line 7.

B. 100

C. A compilation error occurs at line 8.

D. A compilation error occurs at line 15.

Browse 207 Q&As
Questions 12

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)) //line n2

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

What is the result?

A. 4000.0

B. 4000

C. A compilation error occurs at line n1.

D. A compilation error occurs at line n2.

Browse 207 Q&As
Questions 13

Given:

class UserException extends Exception { }

class AgeOutOfLimitException extends UserException { }

and the code fragment:

class App {

public void doRegister(String name, int age)

throws UserException, AgeOutOfLimitException {

if (name.length () <= 60) {

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 {

App t = new App ();

A. doRegister("Mathew", 60); } } What is the result?

B. User is registered.

C. An AgeOutOfLimitException is thrown.

D. A UserException is thrown.

E. A compilation error occurs in the main method.

Browse 207 Q&As
Exam Code: 1Z0-809
Exam Name: Java SE 8 Programmer II
Last Update: May 06, 2024
Questions: 207 Q&As

PDF

$49.99

VCE

$59.99

PDF + VCE

$67.99