Computer Knowledge
Java Core Classes and Threads
1,473 Questions
Java core classes and threads form the foundation of object oriented programming and are crucial for IT officer and programming exams. This includes concepts like string mutability, collections, and multithreading. Solve these questions to test your practical coding and theoretical knowledge.
String and StringBuffer classesThread execution methodsJava collections frameworkCharacter streams input outputVariable serialization rules
Java Core Classes and Threads Questions
-
Property-Map-Value calls a Rule-Obj-MapValue once, and Property-Map-ValuePair calls it twice
-
Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass two row inputs
-
Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass a single row input and single column input
-
Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass multiple row inputs
C
Correct answer
Explanation
This is a duplicate of question 146856. The Property-Map-Value method takes a single row input to evaluate a 1D map value, whereas Property-Map-ValuePair takes both a row input and a column input to evaluate a 2D map value.
-
Use the Java method
-
AtSetValue(PropertyName, Value)
-
Use the Property-Set method
-
{PropertyName INPUT}
C
Correct answer
Explanation
The Property-Set method is the standard way to update property values in activity steps. It efficiently sets property values without requiring direct Java code. Option B's AtSetValue is incorrect, and Option A's Java method is not the recommended approach in PRPC.
-
Property-Map-Value calls a Rule-Obj-MapValue once, and Property-Map-ValuePair calls it twice
-
Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass two row inputs
-
Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass a single row input and single column input
-
Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass multiple row inputs
C
Correct answer
Explanation
The Property-Map-Value method evaluates a 1D map value rule using a single row input. The Property-Map-ValuePair method evaluates a 2D map value rule, which accepts both a row input and a column input to look up a value.
-
(a) Property-Map-Value calls a Rule-Obj-MapValue once, and Property-Map-ValuePair calls it twice
-
(b) Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass two row inputs
-
(c) Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass a single row input and single column input
-
(d) Property-Map-Value can call a Rule-Obj-MapValue and pass a single row input, and Property-Map-Value-Pair can call a Rule-Obj-Map Value and pass multiple row inputs
C
Correct answer
Explanation
Property-Map-Value calls a Rule-Obj-MapValue with a single row input. Property-Map-ValuePair calls the same Rule-Obj-MapValue but passes a single row AND a single column input, allowing lookups that depend on two dimensions. Option A is incorrect about the number of calls. Option B incorrectly mentions 'two row inputs'. Option D incorrectly mentions 'multiple row inputs'.
-
(a) Forward chaining
-
(b) Backward chaining
-
©front chaining
-
(d) none of these
B
Correct answer
Explanation
Property-Seek-Value is used to invoke backward chaining. In backward chaining, the system seeks a value only when needed (on-demand) rather than deriving it proactively. This is a lazy evaluation approach where the value is computed when first requested.
-
(a) Activity-End
-
(b) End-Activity
-
(c) Exit-Activity
-
(d) none of these
C
Correct answer
Explanation
The Exit-Activity method is specifically designed to terminate the current activity's processing and return control to the calling activity. This is the standard method name used in Pega/Process Commander for activity termination, unlike Activity-End or End-Activity which are not valid method names in the system.
B
Correct answer
Explanation
A list containing a null string ("") contains one element (the empty string), whereas an empty list () contains zero elements. Because their lengths and contents differ, they are not equivalent in Perl or general list operations.
-
Hashtable can have null value
-
HashMap can have null value
-
Hashtable is unsynchronized
-
HashMap is synchronized
B
Correct answer
Explanation
HashMap allows null keys and null values, whereas Hashtable does not permit either. Hashtable is synchronized (thread-safe) while HashMap is unsynchronized, making HashMap faster for non-concurrent use. The key distinction is HashMap's null support and Hashtable's legacy synchronized design.
-
a.java.lang.Cloneable
-
b.java.util.Collection
-
c. java.io.Reader
-
d. java.lang.Runnable
A
Correct answer
Explanation
Cloneable is a marker interface - it has no methods and serves only to flag that an object can be cloned. Collection, Reader, and Runnable all declare methods. Marker interfaces like Cloneable, Serializable, and Remote are used to signal special JVM treatment rather than define behavior contracts.
-
By using sizeof operator
-
By calling malloc method
-
By calling getObjectSize method of Object
-
None
D
Correct answer
Explanation
Java has no sizeof operator or built-in way to get object size at runtime. The malloc method doesn't exist in Java (memory management is automatic), and Object class has no getObjectSize method. Object size is implementation-dependent and not directly accessible.
-
You can call a method on null: x.m() will not throw an error when x is null and m is a static method.
-
null instanceof Object returns true
-
You can pass null as the literal argument to a constructor of an anonymous inner class. e.g., new SomeClass(null) { }
-
None of above
A
Correct answer
Explanation
When you call a static method on a null reference (x.m() where x is null and m is static), Java doesn't throw NullPointerException because static methods are bound to the class, not the instance. The other options are false: null instanceof Object is false, and passing null to anonymous inner class constructor is generally problematic.
-
You forgot the hashCode method
-
You didn't handle circular references properly
-
Could be any / both of above
-
None of above
C
Correct answer
Explanation
Hashtable relies on both equals() and hashCode() to store and locate keys. If you override equals() but not hashCode(), equal objects will have different hash codes, preventing Hashtable from finding them. Circular references can also cause infinite loops or incorrect behavior during lookup.
-
java.lang.Error
-
java.lang.Throwable
-
java.lang.Util
-
java.lang.CheckedException
B
Correct answer
Explanation
In Java's exception hierarchy, Throwable is the base class for all throwable objects. Exception inherits directly from Throwable, while Error is a separate subclass of Throwable for serious system errors that applications typically shouldn't catch.
-
UncheckedException
-
CheckedException
-
Error
-
UnspecifiedException
C
Correct answer
Explanation
StackOverflowError and OutOfMemoryError are both subclasses of java.lang.Error, not Exception. Errors represent serious problems that applications should not typically catch - they indicate JVM-level issues rather than application logic problems.
-
It will go for Garbage Collector
-
It remains in Stack
-
It will not create any object
-
Exception objects will not put load on JVM
A
Correct answer
Explanation
After an exception is handled and no references to the exception object remain, it becomes eligible for garbage collection like any other dereferenced Java object. It does not remain permanently on the stack.