Oracle 1Z0-804 Certification Sample Questions and Answers

1Z0-804 PDF, 1Z0-804 Dumps PDF Free Download, 1Z0-804 Dumps Free, 1Z0-804 Latest Dumps PDF, 1Z0-804 PDF Free DownloadThe Oracle 1Z0-804 Sample Question Set is designed to help you prepare for the Java SE 7 Programmer II (1Z0-804) certification exam. To become familiar with actual Oracle Certification exam environment, we suggest you to try Sample Oracle 1Z0-804 Certification Practice Exam.

This sample Oracle 1Z0-804 certification practice exam is designed for evaluation purposes only. If you really want to test your knowledge to identify your weak areas and familiarize with actual exam format, we suggest you to practice with Premium Oracle 1Z0-804 Certification Practice Exam for Java SE 7 Programmer II (1Z0-804) certification. Our team of Java experts have designed Questions-Answers for this premium practice exam by collecting inputs from recently certified candidates. Hence, We strongly recommend you to use Premium Oracle 1Z0-804 Certification Practice Exam to clear your actual Oracle 1Z0-804 Certification Exam with great score.

1Z0-804 Sample Questions:

01.Given:
class MySort implements Comparator<Integer> {
 public int compare(Integer x, Integer y) {
 return y.compareTo(x);
 }
}
And the code fragment:
 Integer[] primes = {2, 7, 5, 3};
 MySort ms = new MySort();
 Arrays.sort(primes, ms);
 for (Integer p2 : primes) {
 System.out.print(p2 + " ");
 }
What is the result?
a) 2 3 5 7
b) 2 7 5 3
c) 7 5 3 2
d) Compilation fails.
 
02. Given:
class MyKeys {
 Integer key;
 MyKeys(Integer k) {
 key = k;
 }
 public boolean equals(Object o) {
 return ((MyKeys) o).key == this.key;
 }
}
And this code snippet:
Map m = new HashMap();
MyKeys m1 = new MyKeys(1);
MyKeys m2 = new MyKeys(2);
MyKeys m3 = new MyKeys(1);
MyKeys m4 = new MyKeys(new Integer(2));
m.put(m1, "car");
m.put(m2, "boat");
m.put(m3, "plane");
m.put(m4, "bus");
System.out.print(m.size());
What is the result?
a) 2
b) 3
c) 4
d) Compilation fails.
 
03. Given:
import java.util.*;
public class MyScan {
 public static void main(String[] args) {
 String in = "1 a 10 . 100 1000";
 Scanner s = new Scanner(in);
 int accum = 0;
 for (int x = 0; x < 4; x++) {
 accum += s.nextInt();
 }
 System.out.println(accum);
 }
}
What is the result?
a) 11
b) 111
c) 1111
d) An exception is thrown at runtime.
 
04. Given:
class Class1 { String v1; }
class Class2 {
 Class1 c1;
 String v2;
}
class Class3 {
 Class2 c1;
 String v3;
}
Which three options correctly describe the relationship between the classes?
a) Class2 has-a v3
b) Class1 has-a v2
c) Class2 has-a v2
d) Class3 has-a v1
e) Class2 has-a Class3
f) Class2 has-a Class1
 
05. Given:
public class Truthy {
 public static void main(String[] args) {
 int x = 7;
 assert (x == 6) ? "x == 6" : "x != 6";
 }
}
What is the result if you try to compile Truthy.java and then run it with assertions enabled?
a) Truthy.java does NOT compile.
b) Truthy.java compiles and the output is x != 6.
c) Truthy.java compiles and an AssertionError is thrown with no additional output.
d) Truthy.java compiles and an AssertionError is thrown with x != 6 as additional output.
 
06. Given:
public class Bees {
 public static void main(String[] args) {
 try {
 new Bees().go();
 } catch (Exception e) {
 System.out.println("thrown to main");
 }
 }
 synchronized void go() throws InterruptedException {
 Thread t1 = new Thread();
 t1.start();
 System.out.print("1 ");
 t1.wait(5000);
 System.out.print("2 ");
 }
}
What is the result?
a) The program prints 1 then 2 after 5 seconds
b) The program prints: 1 thrown to main
c) The program prints: 1 2 thrown to main
d) The program prints:1 then t1 waits for its notification.
 
07. What are two differences between Callable and Runnable?
a) A callable can return a value when executing, but a Runnable cannot.
b) A callable can be executed by a ExecutorService, but a Runnable cannot.
c) A Callable can be passed to a Thread, but a Runnable cannot.
d) A callable can throw an Exception when executing, but a Runnable cannot.
 
08. Given:
import java.text.*;
public class Align {
 public static void main(String[] args) throws ParseException {
 String[] sa = {"111.234", "222.5678"};
 NumberFormat nf = NumberFormat.getInstance();
 nf.setMaximumFractionDigits(3);
 for (String s : sa) {
 System.out.println(nf.parse(s));
 }
 }
}
What is the result?
A)
111.234
222.567
B)
111.234
222.568
C)
111.234
222.5678
D) An exception is thrown at runtime.
 
09. Given the code fragment:
try {
// assume "conn" is a valid Connection object
// assume a valid Statement object is created
// assume rollback invocations will be valid
// use SQL to add 10 to a checking account
Savepoint s1 = conn.setSavePoint();
// use SQL to add 100 to the same checking account
Savepoint s2 = conn.setSavePoint();
// use SQL to add 1000 to the same checking account
// insert valid rollback method invocation here
} catch (Exception e) { }
Which two statements are true?
a) If conn.rollback(s1) is inserted, account will be incremented by 10.
b) If conn.rollback(s1) is inserted, account will be incremented by 1010.
c) If conn.rollback(s2) is inserted, account will be incremented by 100.
d) If conn.rollback(s2) is inserted, account will be incremented by 110.
e) If conn.rollback(s2) is inserted, account will be incremented by 1110.
 
10. Which type of ExecutorService supports the execution of tasks after a fixed delay?
a) DelayedExecutorService
b) ScheduledExecutorService
c) TimedExecutorService
d) FixedExecutorService
e) FutureExecutorService

Solutions:

QUESTION: 01

Answer: c

QUESTION: 02

Answer: c

QUESTION: 03

Answer: d

QUESTION: 04

Answer: c, d, f

QUESTION: 05

Answer: a

QUESTION: 06

Answer: b

QUESTION: 07

Answer: a, d

QUESTION: 08

Answer: c

QUESTION: 09

Answer: a, d

QUESTION: 10

Answer: b

Rating: 5 / 5 (35 votes)