This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Q 1 - What is Serialization?
A - Serialization is the process of writing the state of an object to another object.
B - Serialization is the process of writing the state of an object to a byte stream.
Serialization is the process of writing the state of an object to a byte stream.
Q 2 - What is Deserialization?
A - Deserialization is the process of restoring state of an object from a byte stream.
B - Serialization is the process of restoring state of an object from an object.
Deserialization is the process of restoring state of an object from a byte stream.
Q 3 - What is a transient variable?
A - A transient variable is a variable which is serialized during Serialization.
B - A transient variable is a variable that may not be serialized during Serialization.
C - A transient variable is a variable which is to be marked as serializable.
A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization.
Q 4 - What is synchronization?
A - Synchronization is the capability to control the access of multiple threads to shared resources.
B - Synchronization is the process of writing the state of an object to another object.
C - Synchronization is the process of writing the state of an object to byte stream.
Synchronization is the capability to control the access of multiple threads to shared resources. synchronized keyword in java provides locking which ensures mutual exclusive access of shared resource and prevent data race.
Q 5 - Does garbage collection guarantee that a program will not run out of memory?
Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.
Q 6 - Under what conditions is an object's finalize() method invoked by the garbage collector?
A - When it detects that the object has become unreachable.
B - As soon as object is set as null.
The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.
Q 7 - Which arithmetic operations can result in the throwing of an ArithmeticException?
Integer / and % can result in the throwing of an ArithmeticException.
Yes, try statements be nested.
Q 9 - What will happen if static modifier is removed from the signature of the main method?
B - RunTime Error: NoSuchMethodError.
C - Program will compile and run without any output.
D - Program will compile and run to show the required output.
Program throws "NoSuchMethodError" error at runtime.
No, a top level class can not be private or protected. It can have either "public" or no modifier.
It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.
Q 12 - Is it necessary that each try block must be followed by a finally block?
It is not necessary that each try block must be followed by a finally block. It should be followed by either a catch block or a finally block.
Q 13 - What is runtime polymorphism?
Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass.
No, constructor cannot be inherited.
Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node.
Q 16 - What is currentThread()?
A - It is a Thread public static method used to obtain a reference to the current thread.
B - It is a thread's instance method used to get thread count.
C - It is a object's public static method used obtain a reference to the current thread.
D - It is a object's instance method used to get thread count.
currentThread() is a public static method of Thread class used to obtain a reference to the current thread.
All threads must implement the run() method.
Q 18 - What is a marker interface?
A - marker interface is an interface with no method.
B - marker interface is an interface with single method, mark().
C - marker interface is an interface with single method, marker().
Marker interface is an interface with no method.
Q 19 - Which of the following is a marker interface?
serializable is a marker interface.
Q 20 - Which of the following is a thread safe?
StringBuffer is thread safe.
Q 21 - Which of the following is Faster, StringBuilder or StringBuffer?
StringBuilder is faster than StringBuffer.
Postfix operators i.e () [] . is at the highest precedence.
Q 23 - This is the parent of Error and Exception classes.
Throwable is the parent of both Error and Exception class.
Q 24 - When finally block gets executed?
A - Always when try block get executed, no matter exception occured or not.
B - Always when a method get executed, no matter exception occured or not.
C - Always when a try block get executed, if exception do not occur.
Always when try block get executed, no matter exception occured or not.
Q 25 - In which case, a program is expected to recover?
A program is expected to recover if an exception occurs.
Question Number | Answer Key |
---|---|
1 | B |
2 | A |
3 | B |
4 | A |
5 | B |
6 | A |
7 | A |
8 | A |
9 | B |
10 | B |
11 | B |
12 | B |
13 | A |
14 | B |
15 | A |
16 | A |
17 | D |
18 | A |
19 | A |
20 | B |
21 | A |
22 | A |
23 | A |
24 | A |
25 | B |