OCJP Mock JGI - II assesses advanced Java programming skills, focusing on serialization, I\/O operations, and Java interfaces. The quiz tests error handling, file operations, and regex usage, essential for Java certification preparation.
System.out.printf("|%7d| \n", d);
System.out.printf("|%7f| \n", d);
System.out.printf("|%3.7d| \n", d);
System.out.printf("|%3.7f| \n", d);
System.out.printf("|%7.3d| \n", d);
System.out.printf("|%7.3f| \n", d);
Rate this question:
0
1
2
3
4
6
Rate this question:
It can be any class.
No class has access to base.
The class must belong to the geometry package.
The class must be a subclass of the class Hypotenuse.
Rate this question:
Tea
Coffee
Coffee Tea
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
Rate this question:
1
2
3
4
5
Rate this question:
Three
Other
An exception is thrown at runtime.
Compilation fails because of an error on line 12.
Compilation fails because of an error on line 13.
Compilation fails because of an error on line 15.
Rate this question:
Compilation will succeed for all classes and interfaces.
Compilation of class C will fail because of an error in line 2.
Compilation of class C will fail because of an error in line 6.
Compilation of class AImpl will fail because of an error in line 2.
Rate this question:
4
5
8
9
Compilation fails.
An exception is thrown at runtime.
It is impossible to determine for certain.
Rate this question:
Foofoofoofoofoo
Foobarfoobarbar
Foobarfoofoofoo
Foobarfoobarfoo
Barbarbarbarbar
Foofoofoobarbar
Foofoofoobarfoo
Rate this question:
2
3
4
6
7
Compilation fails
Rate this question:
No output is produced. 1 2 3
No output is produced. 2 3 4
No output is produced. 1 2 3 4
An exception is thrown at runtime. 1 2 3
An exception is thrown at runtime. 2 3 4
An exception is thrown at runtime. 1 2 3 4
Rate this question:
W-f
F-p w-f
W-f b-f
F-p w-f b-f
Compilation fails.
An exception is thrown at runtime.
Rate this question:
300-100-100-100-100
300-300-100-100-100
300-300-300-100-100
300-300-300-300-100
Rate this question:
Line 92 will not execute.
The connection will not be retrieved in line 85.
The resource connection will not be closed on line 88.
The enclosing method will throw an exception to its caller.
Rate this question:
Java MainClass if run from the /apps directory
Java com.company.application.MainClass if run from the /apps directory
Java -classpath /apps com.company.application.MainClass if run from any directory
Java -classpath . MainClass if run from the /apps/com/company/application directory
Java -classpath /apps/com/company/application:. MainClass if run from the /apps directory
Java com.company.application.MainClass if run from the /apps/com/company/application directory
Rate this question:
The output could be 8-1 7-2 8-2 7-1
The output could be 7-1 7-2 8-1 6-1
The output could be 8-1 7-1 7-2 8-2
The output could be 8-1 8-2 7-1 7-2
Rate this question:
Set set = new TreeSet();
Set set = new HashSet();
Set set = new SortedSet();
List set = new SortedList();
Set set = new LinkedHashSet();
Rate this question:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
A runtime error occurs when line 25 executes.
Compilation fails because of an error on line 28.
Rate this question:
[1, 2, 3, 5]
[2, 1, 3, 5]
[2, 5, 3, 1]
[5, 3, 2, 1]
[1, 3, 5, 2]
Compilation fails.
An exception is thrown at runtime.
Rate this question:
String regex = "";
String regex = " ";
String regex = ".*";
String regex = "\\s";
String regex = "\\.\\s*";
String regex = "\\w[ \.] +";
Rate this question:
The time to find the value from HashMap with a Person key depends on the size of the map.
Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.
The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.
Rate this question:
ClassCastException
NullPointerException
NoClassDefFoundError
NumberFormatException
ArrayIndexOutOfBoundsException
Rate this question:
Public void m1() { }
Protected void m1() { }
Private void m1() { }
Void m2() { }
Public void m2() { }
Protected void m2() { }
Private void m2() { }
Rate this question:
Hello
Hello World
Compilation fails
Hello World 5
The code runs with no output
An exception is thrown at runtime
Rate this question:
Compilation succeeds.
Exactly one class does NOT compile.
Exactly two classes do NOT compile.
Exactly four classes do NOT compile.
Exactly three classes do NOT compile.
Rate this question:
1 2 3
Compilation fails because of an error in line 12.
Compilation fails because of an error in line 13.
Compilation fails because of an error in line 14.
A ClassCastException is thrown at runtime.
Rate this question:
6
7
10
11
Compilation fails.
An exception is thrown at runtime.
Rate this question:
True
Not true
An exception is thrown at runtime.
Compilation fails because of an error at line 12.
Compilation fails because of an error at line 19.
Rate this question:
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 20.
Compilation fails because of an error in line 21.
Compilation fails because of an error in line 23.
Compilation fails because of an error in line 25.
Rate this question:
Public void foo() {}
Public int foo() { return 3; }
Public Two foo() { return this; }
Public One foo() { return this; }
Public Object foo() { return this; }
Rate this question:
Foo.notify();
Bar.notify();
Foo.notifyAll();
Thread.notify();
Bar.notifyAll();
Object.notify();
Rate this question:
The code will deadlock.
The code may run with no output.
An exception is thrown at runtime.
The code may run with output "0 6".
The code may run with output "2 0 6 4".
The code may run with output "0 2 4 6".
Rate this question:
Compilation fails.
An exception is thrown at runtime.
[608, 610, 612, 629] [608, 610]
[608, 610, 612, 629] [608, 610, 629]
[606, 608, 610, 612, 629] [608, 610]
[606, 608, 610, 612, 629] [608, 610, 629]
Rate this question:
Class MinMax { E min = null; E max = null; public MinMax() {} public void put(E value) { /* store min or max */ }
Class MinMax { E min = null; E max = null; public MinMax() {} public void put(E value) { /* store min or max */ }
Class MinMax { E min = null; E max = null; public MinMax() {} public void put(E value) { /* store min or max */ }
Class MinMax { E min = null; E max = null; public MinMax() {} public void put(E value) { /* store min or max */ }
Rate this question:
Point p = Line.getPoint();
Line.Point p = Line.getPoint();
Point p = (new Line()).getPoint();
Line.Point p = (new Line()).getPoint();
Rate this question:
All of the assert statements are used appropriately.
Only the assert statement on line 12 is used appropriately.
Only the assert statement on line 15 is used appropriately.
Only the assert statement on line 18 is used appropriately.
Only the assert statements on lines 12 and 15 are used appropriately.
Only the assert statements on lines 12 and 18 are used appropriately.
Only the assert statements on lines 15 and 18 are used appropriately.
Rate this question:
0, 2, 4, 4, 6, 8, 10, 6,
0, 2, 4, 6, 8, 10, 2, 4,
0, 2, 4, 6, 8, 10, 12, 14,
0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,
0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,
Rate this question:
New Thread() { public void run() { doStuff(); } };
New Thread() { public void start() { doStuff(); } };
New Thread() { public void start() { doStuff(); } }.run();
New Thread() { public void run() { doStuff(); } }.start();
New Thread(new Runnable() { public void run() { doStuff(); } }).run();
New Thread(new Runnable() { public void run() { doStuff(); } }).start();
Rate this question:
X, followed by an Exception.
No output, and an Exception is thrown.
Compilation fails due to an error on line 14.
Compilation fails due to an error on line 16.
Compilation fails due to an error on line 17.
X, followed by an Exception, followed by B.
Rate this question:
The value of b is 2.
The value of a is 3.14.
The value of b is 2.00.
The value of a is 3.141.
The value of a is 3.1415.
The value of a is 3.1416.
The value of b is 2.0000.
Rate this question:
Password: got
Password: got aiko
Password: aiko got aiko
An exception is thrown at runtime.
Compilation fails due to an error on line 8.
Rate this question:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
Rate this question:
0
1
2
3
Compilation fails.
Rate this question:
Public class Employee extends Info implements Data { public void load() { /*do something*/ } }
Public class Employee implements Info extends Data { public void load() { /*do something*/ } }
Public class Employee extends Info implements Data public void load(){ /*do something*/ } public void Info.load(){ /*do something*/ } }
Public class Employee implements Info extends Data { public void Data.load(){ /*do something*/ } public void load(){ /*do something*/ } }
Public class Employee implements Info extends Data { public void load(){ /*do something*/ } public void Info.load(){ /*do something*/ } }
Public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }
Rate this question:
3
23
32
123
321
Compilation fails.
An exception is thrown at runtime.
Rate this question:
TestA
TestB
Compilation fails.
An exception is thrown at runtime.
Rate this question:
Compilation fails because the hashCode method is not overridden.
A HashSet could contain multiple Person objects with the same name.
All Person objects will have the same hash code because the hashCode method is not overridden.
If a HashSet contains more than one Person object with name="Fred", then removing another Person, also with name="Fred", will remove them all.
Rate this question:
System.load("prop.custom");
System.getenv("prop.custom");
System.property("prop.custom");
System.getProperty("prop.custom");
System.getProperties().getProperty("prop.custom");
Rate this question:
Quiz Review Timeline (Updated): Mar 20, 2023 +
Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.
Wait!
Here's an interesting quiz for you.