![](https://knowledgewala.com/wp-content/uploads/2017/05/ocajp.png)
Introduction
This Java test assesses the basic and medium knowledge of Java programming language and OOP principles. Put your Java know-how to the test and see how well you understand its syntax and object oriented programming concepts.
Topics: Java language syntax, object-oriented programming (inheritance, polymorphism), collections, data types, exceptions …
***** Please provide your feedback so we can make it more useful. *****
Please start mock exam by Clicking on Start Quiz Button.
0 of 25 questions completed Questions:
Oracle Java Certification Exams to improve and test knowledge.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
0 of 25 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0) Re-Take Oracle Java Certification Exams to improve and test knowledge. Please select correct output for below code? Which two statements are true? What is the result? Which statement is true? Which statement at Point X on line 1 is required to allow this code to compile? What is the numerical range of a byte? What is the decimal value of j at line 7? Which two expressions evaluate to True? What is the result of below code? Which statement is true? Which statement is true? What is the acceptable type for the variable i? You need to store elements in a collection that guarantees that no duplicates are stored. What happens when this code gets executed? package com.kw.sample; import java.util.SortedSet; public class KWSampleForOCPJP { public static void main(String… args) { } What happens when this code gets executed? NavigableSet extends SortedSet. What is the output of this code? Consider List<E>. What is the signature of the method set? Which are true? package com.kw.sample; public class KWSampleForOCPJP { static String s; static Boolean t1() { static boolean t2() { public static void main(String[] args) { What is the result of compiling and running the following code? package com.kw.sample; public class KWSampleForOCPJP { public static void main(String[] args) { What is the result of compiling and running the following code? Would the following code compile and run? What is the possible results of compiling and running the following code? Which of the following are methods of the Thread class?Oracle Java Certification Exams (OCAJP) Mock Exam Part2
Quiz-summary
Information
Results
Average score
Your score
Categories
Pos.
Name
Entered on
Points
Result
Table is loading
No data available
1. Question
1 points
package com.knowledgewala.sample;
public class KWSampleForSCJP implements Runnable {
public void run() {
System.out.println("run.");
throw new RuntimeException("Problem");
}
public static void main(String[] args) {
Thread t = new Thread(new KWSampleForSCJP());
t.start();
System.out.println("End of method.");
}
}
2. Question
1 points
3. Question
1 points
package com.knowledgewala.sample;
public class KWSampleForSCJP {
public static void main(String args[]) {
class Foo {
public int i = 3;
}
Object o = (Object) new Foo();
Foo foo = (Foo) o;
System.out.println("i = " + foo.i);
}
}
4. Question
1 points
5. Question
1 points
package com.knowledgewala.sample;
//Point X
public class KWSampleForSCJP {
public static void main(String[] args) throws Exception {
jave.io.PrintWriter out = new jave.io.PrintWriter(new jave.io.OutputStreamWriter(System.out), true);
out.println("Hello");
}
}
6. Question
1 points
7. Question
1 points
package com.knowledgewala.sample;
public class KWSampleForSCJP {
public static void main(String args[]) {
int i = 0xFFFFFFF1;
int j = ~i;
}
}
8. Question
1 points
Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);
9. Question
1 points
package com.knowledgewala.sample;
public class KWSampleForSCJP {
private static int j = 0;
private static boolean methodB(int k) {
j += k;
return true;
}
public static void methodA(int i) {
boolean b;
b = i < 10 | methodB(4);
b = i < 10 || methodB(8);
}
public static void main(String[] args)
{
methodA(0);
System.out.println(j);
}
}
10. Question
1 points
package com.knowledgewala.sample;
public class KWSampleForSCJP {
public static void main(String[] args)
{
byte b = 127;
byte c = 126;
byte d = b + c;
}
}
11. Question
1 points
12. Question
1 points
switch (i) {
default:
System.out.println("Hello");
}
13. Question
1 points
Which two interfaces provide that capability?
14. Question
1 points
import java.util.TreeSet;
SortedSet<Integer> set = new TreeSet<Integer>();
set.last();
}
15. Question
1 points
package com.kw.sample;
import java.util.SortedSet;
import java.util.TreeSet;
public class KWSampleForOCPJP {
public static void main(String... args) {
SortedSet<Integer> set = new TreeSet<Integer>();
set.add(7);
set.add(-12);
SortedSet<Integer> sub = set.subSet(-100, 100);
sub.add(9);
System.out.format("%d %d", set.size(), sub.size());
}
}
16. Question
1 points
17. Question
1 points
package com.kw.sample;
import java.util.NavigableSet;
import java.util.TreeSet;
public class KWSampleForOCPJP {
public static void main(String... args) {
NavigableSet<Integer> set = new TreeSet<Integer>();
set.add(-12);
set.add(24);
System.out.format("%d %d %d %d", set.lower(-12), set.lower(0),
set.lower(24), set.lower(100));
}
}
18. Question
1 points
19. Question
1 points
20. Question
1 points
static Boolean b;
return new Boolean(“howdy”);
}
return new Boolean(s);
}
if (t1())
System.out.print(“t1 “);
if (!t2())
System.out.print(“t2 “);
if (t1() != t2())
System.out.print(“!= “);
}
}
21. Question
1 points
int x = 0;
int i = 1;
for (; i > 0; i–)
if ((++x > 0) | (–i > 0))
x++;
System.out.println(x + “” + i);
}
}
22. Question
1 points
package com.kw.sample;
public class KWSampleForOCPJP {
public static void main(String[] args) {
System.out.print("4" + 5);
System.out.print(4 + 5);
System.out.print(4 + 5 + "9");
}
}
23. Question
1 points
package com.kw.sample;
public class KWSampleForOCPJP {
public static void main(String args) {
System.out.println("JavaChamp");
}
}
24. Question
1 points
package com.kw.sample;
public class KWSampleForOCPJP {
static Runnable t1 = new Runnable() {
public void run() {
try {
System.out.print("t1before");
Thread.sleep(100);
System.out.print("t1after");
} catch (InterruptedException e) {
}
}
};
static Thread t2 = new Thread() {
public void run() {
try {
System.out.print("t2before");
synchronized (this) {
wait();
}
System.out.print("t2after");
} catch (InterruptedException e) {
}
}
};
public static void main(String[] args) throws InterruptedException {
new Thread(t1).start();
t2.start();
}
}
25. Question
1 points