Limited-Time Offer: Enjoy 50% Savings! Ends in 00h 00m 00s Coupon code: 50OFF
Skip to content

Free Oracle Java SE 8 Programmer II 1Z0-809 Exam Questions

Page: 1 / 14 Total 208 questions

Want more questions? Get Premium Access.

Question 1

Given the code fragment:

Assume that:

The required database driver is configured in the classpath.

The appropriate database is accessible with the dbURL, userName, and passWord exists

The Employee table has a column ID of type integer and the SQL query matches one record.

What is the result?

Correct Answer: A. Compilation fails at line 14.

Question 2

Which two are elements of a singleton class? (Choose two.)

Correct Answer: B. a public method to instantiate the single instance; D. a private constructor to the class

Question 3

Given the content:

Given the code fragment:

Which two code fragments when inserted at Line 1, independently, enables the code fragment to print "Hallo'?

A.

B.

C.

D.

E.

Correct Answer: A. Option A; B. Option B

Question 4

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. int GDP = Integer.parseInt (br.readline());

Question 5

Given:

and the code fragment:

Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?

Correct Answer: D. .sorted((v1, v2) -> Integer.compare(v1.getVId(), v2.getVid())); E. .sorted(Comparator.comparing ((Vehicle v) -> v.getVId()))

Question 6

Given the code fragment:

Path file = Paths.get (''courses.txt'');

// line n1

Assume the courses.txt is accessible.

Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?

Correct Answer: D. Stream<String> fc = Files.lines (file);fc.forEach (s - > System.out.println(s));

Question 7

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

Correct Answer: B. It accepts one argument and returns boolean.

Question 8

Given the code fragment:

Which code fragment, when inserted at line n1, ensures false is printed?

Correct Answer: B. boolean b = cs.stream() .anyMatch (w -> w.equals (''Java''));

Question 9

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

(o1); } } );

treeMap.putAll (unsortMap);

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

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

}

}

}

What is the result?

Correct Answer: C. j z e b d

Question 10

Given the code fragment:

List list1 = Arrays.asList(10, 20);

List list2 = Arrays.asList(15, 30);

//line n1

Which code fragment, when inserted at line n1, prints 10 20 15 30?

Correct Answer: A. Stream.of(list1, list2).flatMap(list -> list.stream()).forEach(s -> System.out.print(s + '' ''));

Question 11

Given the code fragment:

class CallerThread implements Callable {

String str;

public CallerThread(String s) {this.str=s;}

public String call() throws Exception {

return str.concat(''Call'');

}

}

and

public static void main (String[] args) throws InterruptedException, ExecutionException

{

ExecutorService es = Executors.newFixedThreadPool(4); //line n1

Future f1 = es.submit (newCallerThread(''Call''));

String str = f1.get().toString();

System.out.println(str);

}

Which statement is true?

Correct Answer: B. The program prints Call Call and does not terminate.

Question 12

Given:

public class Customer {

private String fName;

private String lName;

private static int count;

public customer (String first, String last) {fName = first, lName = last;

++count;}

static { count = 0; }

public static int getCount() {return count; }

}

public class App {

public static void main (String [] args) {

Customer c1 = new Customer(''Larry'', ''Smith'');

Customer c2 = new Customer(''Pedro'', ''Gonzales'');

Customer c3 = new Customer(''Penny'', ''Jones'');

Customer c4 = new Customer(''Lars'', ''Svenson'');

c4 = null;

c3 = c2;

System.out.println (Customer.getCount());

}

}

What is the result?

Correct Answer: D. 4

Question 13

Given the code fragment:

Stream files = Files.list(Paths.get(System.getProperty(''user.home'')));

files.forEach (fName -> {//line n1

try {

Path aPath = fName.toAbsolutePath();//line n2

System.out.println(fName + '':''

+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime

());

} catch (IOException ex) {

ex.printStackTrace();

});

What is the result?

Correct Answer: C. The files in the home directory are listed along with their attributes.

Question 14

Given the code fragment:

String str = ''Java is a programming language'';

ToIntFunction indexVal = str: : indexOf; //line n1

int x = indexVal.applyAsInt(''Java'');//line n2

System.out.println(x);

What is the result?

Correct Answer: A. 0

Question 15

Which class definition compiles?

Correct Answer: B. BiFunction<Integer, Integer, String> c = (i, j) --> {System.out.print (i + '','' + j+ ''; '')};