![](https://knowledgewala.com/wp-content/uploads/2017/05/ocajp.png)
Introduction
This tutorial helps to check your knowledge for Java short question for Interview and Certification preparation. Also, it will helps to improve your efficiency and accuracy along with speed of solving questions which matters at the time of exam.
Please start mock exam by Clicking on Start Quiz Button.
***** Please provide your feedback so we can make it more useful. *****
0 of 20 questions completed Questions:
This Quiz helps to improve Java knowledge and will increase the chance of passing Java Certification Exam.
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 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0) Please take test again to check your knowledge for java programming. What is the result? What is the output for the below code? What is the expected output? What notifyAll() method do? Read this piece of code carefully, Please select correct Answer? Read the code below. Will be the result of attempting to compile and run the code below. Read the following code below, please select correct answer? public interface KWSampleForSCJP { A Class implementing this interface should An Interface can never be private or protected. Please select correct answer? Please select correct output of below code – public class KWSampleForSCJP { public static void main(String args[]) { } The class java.lang.Exception Please select correct answer for the following lines of code Please select the correct output of the below code – Which two cause a compiler error? Please select correct output? Which are true about given below code? Please choose only correct answer: What is the result? Please select the correct answers for below code? package com.kw.sample; import java.util.ArrayList; public class KWSampleForOCPJP { public static void main(String… args) { // line 16 } What is the result of compiling and running the following code?Oracle Java Certification Exams (OCAJP) Mock Exam Part1
Quiz-summary
Information
Results
Average score
Your score
Categories
1. Question
1 points
int[] array = { 1, 2, 3, 4, 5, 6 };
int i = array.length - 1;
while (i >= 0) {
System.out.print(a[i]);
i--;
}
2. Question
1 points
public class A {
int add(int i, int j) {
return i + j;
}
}
public class B extends A {
public static void main(String argv[]) {
short s = 9;
System.out.println(add(s, 6));
}
}
3. Question
1 points
public class KWSampleForOCPJP {
public static void main(String[] args) {
boolean stmt1 = "knowledgewala" == "knowledgewala";
boolean stmt2 = new String("knowledgewala") == "knowledgewala";
boolean stmt3 = new String("knowledgewala") == new String(
"knowledgewala");
System.out.println(stmt1 && stmt2 || stmt3);
}
}
4. Question
1 points
5. Question
1 points
if("String".toString() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
6. Question
1 points
public class KWSampleForSCJP {
public void method(Object o) {
System.out.println("Object Verion");
}
public void method(String s) {
System.out.println("String Version");
}
public static void main(String args[]) {
KWSampleForSCJP kwSampleForSCJP = new KWSampleForSCJP();
kwSampleForSCJP.method(null);
}
}
7. Question
1 points
public abstract void someMethod() throws Exception;
}
8. Question
1 points
9. Question
1 points
public class KWSampleForSCJP {
private int i = j;
private int j = 10;
public static void main(String args[]) {
System.out.println((new KWSampleForSCJP()).i);
}
}
10. Question
1 points
System.out.println(“Before Try”);
try {
} catch (Throwable t) {
System.out.println(“Inside Catch”);
}
System.out.println(“At the End”);
}
11. Question
1 points
12. Question
1 points
byte b = 0;
b += 1;
13. Question
1 points
public class KWSampleForSCJP {
private void method1() throws Exception {
throw new RuntimeException();
}
public void method2() {
try {
method1();
} catch (RuntimeException e) {
System.out.println("Caught Runtime Exception");
} catch (Exception e) {
System.out.println("Caught Exception");
}
}
public static void main(String args[]) {
KWSampleForSCJP kwSampleForSCJP = new KWSampleForSCJP();
kwSampleForSCJP.method2();
}
}
14. Question
1 points
15. Question
1 points
public class KWSampleForSCJP {
public static void main(String args[]) {
int i = 1, j = 10;
do {
if (i++ > --j) {
continue;
}
} while (i < 5);
System.out.println("i = " + i + "and j = " + j);
}
}
16. Question
1 points
public class KWSampleForOCPJP extends Thread {
public static void main(String[] args) {
Thread t = new Thread(new KWSampleForOCPJP());
Thread t2 = new Thread(new KWSampleForOCPJP());
t.start();
t2.start();
}
public static void run() {
for (int i = 0; i < 2; i++)
System.out.print(Thread.currentThread().getName() + " ");
}
}
17. Question
1 points
package com.kw.sample;
public class KWSampleForOCPJP extends Thread {
static int x = 4;
int y = 9;
public KWSampleForOCPJP() {
System.out.print(this.x); // line 7
printVariables();
}
public static void printVariables() {
System.out.print(x); // line 12
System.out.print(y); // line 13
}
public static void main(String... args) { // line 16
new KWSampleForOCPJP();
}
}
18. Question
1 points
package com.kw.sample;
import java.util.ArrayList;
import java.util.List;
public class KWSampleForOCPJP {
class Snack {
static List<String> s1 = new ArrayList<String>();
}
public static void main(String... args) { // line 16
List<String> c1 = new ArrayList<String>();
s1.add("1");
s1.add("2");
c1.add("3");
c1.add("4");
getStuff(s1, c1);
}
static void getStuff(List<String> a1, List a2) {
for (String s1 : a1)
System.out.print(s1 + " ");
for (String s2 : a2)
System.out.print(s2 + " ");
;
}
}
19. Question
1 points
import java.util.List;
int a = 6;
if (a = 6)
System.out.print(“true”);
}
20. Question
1 points
package com.kw.sample;
public class KWSampleForOCPJP {
public static void main(String... args) { // line 16
int x = 0, y = 0;
x = 5 + y++;
System.out.print(x + "" + y);
x = 0;
y = 0;
x = 5 + ++y;
System.out.print(x + "" + y);
}
}
http://kitabxana.net/files/books/file/1354098917.pdf