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

Multiple choice technology web technology
  1. Property-Map-Value calls a Rule-Obj-MapValue once, and Property-Map-ValuePair calls it twice

  2. 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

  3. 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

  4. 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

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. Use the Java method

  2. AtSetValue(PropertyName, Value)

  3. Use the Property-Set method

  4. {PropertyName INPUT}

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. Property-Map-Value calls a Rule-Obj-MapValue once, and Property-Map-ValuePair calls it twice

  2. 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

  3. 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

  4. 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

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. (a) Property-Map-Value calls a Rule-Obj-MapValue once, and Property-Map-ValuePair calls it twice

  2. (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

  3. (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

  4. (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

Reveal answer Fill a bubble to check yourself
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'.

Multiple choice technology web technology
  1. (a) Forward chaining

  2. (b) Backward chaining

  3. ©front chaining

  4. (d) none of these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. (a) Activity-End

  2. (b) End-Activity

  3. (c) Exit-Activity

  4. (d) none of these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. Hashtable can have null value

  2. HashMap can have null value

  3. Hashtable is unsynchronized

  4. HashMap is synchronized

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. a.java.lang.Cloneable

  2. b.java.util.Collection

  3. c. java.io.Reader

  4. d. java.lang.Runnable

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. By using sizeof operator

  2. By calling malloc method

  3. By calling getObjectSize method of Object

  4. None

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. You can call a method on null: x.m() will not throw an error when x is null and m is a static method.

  2. null instanceof Object returns true

  3. You can pass null as the literal argument to a constructor of an anonymous inner class. e.g., new SomeClass(null) { }

  4. None of above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. You forgot the hashCode method

  2. You didn't handle circular references properly

  3. Could be any / both of above

  4. None of above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology platforms and products
  1. java.lang.Error

  2. java.lang.Throwable

  3. java.lang.Util

  4. java.lang.CheckedException

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology platforms and products
  1. UncheckedException

  2. CheckedException

  3. Error

  4. UnspecifiedException

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology platforms and products
  1. It will go for Garbage Collector

  2. It remains in Stack

  3. It will not create any object

  4. Exception objects will not put load on JVM

Reveal answer Fill a bubble to check yourself
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.