Oracle Java Certification Exam was earlier called as SCJP (Sun Certified Java Professional) but after the takeover by Oracle, it’s known as Oracle Java Certification Exam. It is divided into two levels- OCAJP and OCPJP. OCAJP includes Java for beginners, and thus it’s easier than OCPJP whereas OCPJP includes Advanced Java and thus, is complex than OCAJP.
OCA / OCP Java SE 8 Programmer Practice Tests
OCAJP8 (1Z0-808) is the associate level exam for Java SE 8 Programmer and OCPJP8 (1Z0-809) is the professional level exam for Java SE 8 Programmer. The duration of both the programs is same, which is two and a half hours. However, the numbers of questions asked in both the programs are different. In OCAJP 8, the candidate has to answer 80 questions within 150 minutes. While in OCPJP 8, the candidate has to answer 85 questions within the same time limit. The passing score required in both the exams is 65%. You can’t get OCPJP certification from Oracle if you don’t pass OCAJP Oracle Java exam first. Here are the top questions asked in both the 1Z0-809 and 1Z0-909 exams.
Top 10 Questions For OCAJP8 (1Z0-808) Exam:
it is executed as a program?
thrown at runtime.
“);
thrown at runtime.
“instanceof” is use to check whether an object is of a particular
type
false.
error at line 3.
true.
error at line 4.
NullPointerException e){
(a[2]==b[2][1]));
identifiers.
error at line 4.
error at line 7.
thrown.
Top 10 Questions For OCPJP8 (1Z0-809) Exam:
Q1. Consider the following class:
public final class Program {
final private String name;
Program (String name){
this.name = name;
getName();
}
//code here
}
Which of the following codes will make an instance of this class immutable?
A. public String getName(){return name;}
B. public String getName(String value){ name=value; return value;}
C. private String getName(){return name+"a";}
D. public final String getName(){return name+="a";}
E. All of Above.
Q2. Consider the following code:
1. class SuperClass{
2. protected void method1(){
3. System.out.print("M SuperC");
4. }
5. }
6.
7. class SubClass extends SuperClass{
8. private void method1(){
9. System.out.print("M SubC");
10. }
11.
12. public static void main(String[] args){
13. SubClass sc = new SubClass();
14. sc.method1();
15. }
16. }
What will be the result?
A. M SubC.
B. M SuperC.
C. M SuperCM SubC.
D. Compilation fails.
E. None of above.
Q3. Given the following class:
1. public class Test {
2. public static void main(String args[]) {
3. //Code Here
4. Thread thread = new Thread(r);
5. thread.start();
6. }
7. }
Which of the following lines will give a valid Thread creation?
A. Thread r = () -> System.out.println("Running");
B. Run r = () -> System.out.println("Running");
C. Runnable r = () -> System.out.println("Running");
D. Executable r = () -> System.out.println("Running");
E. None Of Above
Q4. Which of the following database urls are correct?
A. jdbc:mysql://localhost:3306
B. jdbc:mysql://localhost:3306/sample
C. jdbc:mysql://localhost:3306/sample/user=root?password=secret
D. jdbc:mysql://localhost:3306/sample?user=root&password=secret
E. All
Q5. Given the following code:
1. public class Program {
2.
3. public static void main (String args[]) throws IOException {
4. Console c = System.console();
5. int i = (int)c.readLine("Enter value: ");
6. for (int j = 0; j < i; j++) {
7. c.format(" %2d",j);
8. }
9. }
10. }
What will be the result of entering the value 5?
A. 1 2 3 4 5
B. 0 1 2 3 4
C. 0 2 4 6 8
D. The code will not compile because of line 5.
E. Unhandled exception type NumberFormatException at line 7.
Q6. Given the following class:
1. class Singleton {
2. private int count = 0;
3. private Singleton(){};
4. public static final Singleton getInstance(){ return new Singleton(); };
5. public void add(int i){ count+=i; };
6. public int getCount(){ return count;};
7. }
8.
9. public class Program {
10. public static void main(String[] args) {
11. Singleton s1 = Singleton.getInstance();
12. s1.add(3);
13. Singleton s2 = Singleton.getInstance();
14. s2.add(2);
15. Singleton s3 = Singleton.getInstance();
16. s2.add(1);
17. System.out.println(s1.getCount()+s2.getCount()+s3.getCount());
18. }
19. }
What will be the result?
A. 18
B. 7
C. 6
D. The code will not compile.
E. None of above
Q7. Given the following class:
1. public class Program {
2.
3. public static void main(String[] args) {
4.
5. List list = Arrays.asList(4,6,12,66,3);
6.
7. String s = list.stream().map( i -> {
8. return ""+(i+1);
9. }).reduce("", String::concat);
10.
11. System.out.println(s);
12. }
13. }
What will be the result?
A. 4612663
B. 5713674
C. 3661264
D. The code will not compile because of line 7.
E. Unhandled exception type NumberFormatException al line 8.
Q8. Which of the following are correct overrides of Object class?
I. public int hashCode();
II. public String toString();
III. public boolean equals(Object obj);
IV. public Class getClass();
A. I, II, III, IV.
B. I, II, III.
C. I, II.
D. III, IV.
E. All.
Q9. Consider the following class:
1. public class Test {
2. public static int count(T[] array, T elem) {
3. int count = 0;
4. for (T e : array)
5. if( e.compareTo(elem) > 0) ++count;
6.
7. return count;
8. }
9. public static void main(String[] args) {
10. Integer[] a = {1,2,3,4,5};
11. int n = Test.count(a, 3);
12. System.out.println(n);
13. }
14. }
What will be the result?
A. 2
B. 3
C. The code will not compile because of line 5.
D. An exception is thrown.
E. None of Above.
Q10. Given the following class:
1. public class Program {
2. public static void main(String[] args) {
3.
4. Thread th = new Thread(new Runnable(){
5.
6. static {
7. System.out.println("initial");
8. }
9.
10. @Override
11. public void run() {
12. System.out.println("start");
13. }
14. });
15.
16. th.start();
17. }
18. }
What will be the result?
A. start initial
B. initial start
C. initial
D. A runtime exception is thrown.
E. The code will not compile because of line 6.
Although above are the few best Java certification questions, it’s recommended to go through each topic in detail, and practice questions as the questions vary in each Oracle Java Certification Exam.