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.
Closing an open stream.
Flushing an open stream.
Writing to an open stream.
Writing a line separator to an open stream.
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:
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:
String regex = "";
String regex = " ";
String regex = ".*";
String regex = "\\s";
String regex = "\\.\\s*";
String regex = "\\w[ \.] +";
Rate this question:
Compilation fails because of an error in line 3.
Compilation fails because of an error in line 7.
Compilation fails because of an error in line 9.
If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
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:
Foofoofoofoofoo
Foobarfoobarbar
Foobarfoofoofoo
Foobarfoobarfoo
Barbarbarbarbar
Foofoofoobarbar
Foofoofoobarfoo
Rate this question:
Raccoon is-a Mammal.
Raccoon has-a Mammal.
BabyRaccoon is-a Mammal.
BabyRaccoon is-a Raccoon.
BabyRaccoon has-a Mammal.
BabyRaccoon is-a BabyRaccoon.
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 m1() { }
Protected void m1() { }
Private void m1() { }
Void m2() { }
Public void m2() { }
Protected void m2() { }
Private void m2() { }
Rate this question:
Has-a relationships should never be encapsulated.
Has-a relationships should be implemented using inheritance.
Has-a relationships can be implemented using instance variables.
Is-a relationships can be implemented using the extends keyword.
Is-a relationships can be implemented using the implements keyword.
The relationship between Movie and Actress is an example of an is-a relationship.
An array or a collection can be used to implement a one-to-many has-a relationship.
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:
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:
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:
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:
2
3
4
6
7
Compilation fails
Rate this question:
3
23
32
123
321
Compilation fails.
An exception is thrown at runtime.
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:
Public class Session implements Runnable, Cloneable { public void run(); public Object clone(); }
Public class Session extends Runnable, Cloneable { public void run() { /* do something */ } public Object clone() { /* make a copy */ }
Public class Session implements Runnable, Cloneable { public void run() { /* do something */ } public Object clone() { /* make a copy */ }
Public abstract class Session implements Runnable, Cloneable { public void run() { /* do something */ } public Object clone() { /*make a copy */ }
Public class Session implements Runnable, implements Cloneable { public void run() { /* do something */ } public Object clone() { /* make a copy */ }
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:
Point p = Line.getPoint();
Line.Point p = Line.getPoint();
Point p = (new Line()).getPoint();
Line.Point p = (new Line()).getPoint();
Rate this question:
TestA
TestB
Compilation fails.
An exception is thrown at runtime.
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:
1
2
3
4
5
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:
Foo.notify();
Bar.notify();
Foo.notifyAll();
Thread.notify();
Bar.notifyAll();
Object.notify();
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:
4
5
8
9
Compilation fails.
An exception is thrown at runtime.
It is impossible to determine for certain.
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:
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:
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:
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:
[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:
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:
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:
Tea
Coffee
Coffee Tea
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
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:
Set set = new TreeSet();
Set set = new HashSet();
Set set = new SortedSet();
List set = new SortedList();
Set set = new LinkedHashSet();
Rate this question:
B
B, followed by an Exception.
Compilation fails due to an error on line 9.
Compilation fails due to an error on line 14.
An Exception is thrown with no other output.
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:
23
234
235
2345
2357
23457
Compilation fails.
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:
Test
Exception
Compilation fails.
NullPointerException
Rate this question:
6
7
10
11
Compilation fails.
An exception is thrown at runtime.
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:
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:
ClassCastException
NullPointerException
NoClassDefFoundError
NumberFormatException
ArrayIndexOutOfBoundsException
Rate this question:
Int []x = {1,2,3,4,5}; for(int y = 0; y < 6; y++) System.out.println(x[y]);
Static int[] x = {7,6,5,4}; static { x[1] = 8; x[4] = 3; }
for(int y = 10; y < 10; y++) doStuff(y);
Void doOne(int x) { doTwo(x); } void doTwo(int y) { doThree(y); } void doThree(int z) { doTwo(z); }
For(int x = 0; x < 1000000000; x++) doStuff(x);
Void counter(int i) { counter(++i); }
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.