Computer Knowledge

Java Core Classes and Threads

1,935 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 programming languages
  1. mid(2,s);

  2. charAt(2);

  3. s.indexOf('v');

  4. indexOf(s,'v');

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The indexOf method returns the position of a specified character or substring within a string. For the string "Java", indexOf('v') returns 2 because it's zero-indexed (J=0, a=1, v=2). Option A and B reference non-existent methods, and option D has incorrect parameter order.

Multiple choice technology programming languages
  1. The AutoEventWireup attribute is set to False

  2. The AutomaticPostBack attribute is set to False

  3. The codebehind module is not properly compiled

  4. The ListBox must be defined WithEvents

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

SelectedIndexChanged event execution depends on AutoPostBack being True for ListBox controls. AutoEventWireup affects event-wireup behavior, not postback execution, and other options are unrelated to this specific issue.

Multiple choice technology programming languages
  1. Sets all properties to their initial value

  2. Sets all properties to null

  3. Repopulates all properties from the request parameters

  4. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The reset() method in ActionForm does NOT set properties to initial values (A), does NOT set them to null (B), and does NOT repopulate from request parameters (C) - that's what populate() does. The default reset() implementation is typically empty, and subclasses override it to set specific default values, making 'None of the above' correct.

Multiple choice technology programming languages
  1. A blank page will be displayed.

  2. A page with the text Welcome is displayed

  3. An exception will be thrown because the implicit out object is not used

  4. An exception will be thrown because PrintWriter can be used in servlets only

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The JSP page will display 'Welcome' because the code uses request.getWriter() which is valid in JSP. While JSP provides an implicit 'out' object, using PrintWriter directly is also allowed. The code correctly obtains a PrintWriter from the request object and writes 'Welcome' to it. There's no rule preventing PrintWriter usage in JSP - it's a valid Java object.

Multiple choice technology platforms and products
  1. getAttributeValue(context, Attributename)

  2. getInfo(context,"attribute[" + AttributeName +"].value")

  3. getAttributeValues(context, boolean)

  4. All the above.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

All listed methods (D) can retrieve attribute values from DomainObject/BusinessObject classes. getAttributeValue gets single attributes, getInfo with attribute path syntax retrieves values, and getAttributeValues returns multiple values. Different methods serve different use cases.

Multiple choice technology platforms and products
  1. getAttributeValue(context, Attributename)

  2. getInfo(context,"attribute[" + AttributeName +"].value")

  3. getAttributeValues(context, boolean)

  4. All the above.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

All three methods can retrieve attribute values from BusinessObjects in the Matrix API. getAttributeValue directly returns the value, getInfo uses a context-based expression string to access attributes, and getAttributeValues can return multiple values with boolean control flags. These methods offer different interfaces for the same functionality - direct access, expression-based access, and multi-value retrieval.

Multiple choice technology programming languages
  1. CreateObjRef

  2. BeginExecuteNonQuery

  3. Prepare

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

SqlCommand inherits CreateObjRef from MarshalByRefObject (base class of all .NET objects), implements BeginExecuteNonQuery for asynchronous query execution, and has Prepare to optimize parameterized commands. All three are valid methods available on a SqlCommand object.

Multiple choice technology web technology
  1. Due to its nature as a reference type, StringBuilder has a smaller footprint than string,thereby allowing more efficent memory management.

  2. StringBuilder is inherently more efficent due to its nature as a reference type comparedto string, which is a value type

  3. StringBuilder allows for dynamic appending of types; string creates a new string every time it is appended to.

  4. StringBuilder has the ability to accept objects other than string in order to build a string by automatically calling the ToString method on the object.

  5. Regular expressions are built into StringBuilder, allowing for much more efficent text processing than what could usually be achieved by using a string.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

StringBuilder is mutable and efficient for multiple string modifications. Each string append creates a new string object in memory (strings are immutable), while StringBuilder modifies the same buffer internally, reducing memory allocations and garbage collection pressure. Options A and B incorrectly claim string is a value type (it's a reference type).

Multiple choice technology web technology
  1. It is invoked every 40 seconds until the process is destroyed.

  2. It only occurs when the Collect method is explicitly invoked in the System.GC class.

  3. It is invoked every time a constructor is called.

  4. It is invoked when generation 0 does not have room for the newly created object.

  5. It is invoked when the Dispose method is explicitly called.

Reveal answer Fill a bubble to check yourself
E Correct answer
Multiple choice technology web technology
  1. Cannot prevent it

  2. This type of situation will never arrise

  3. Before performing your update, call DisableEventFiring(). After update, call EnableEventFiring().

  4. Before performing your update, call EnableEventFiring(). After update, call DisableEventFiring().

  5. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

When an event receiver updates the item it's handling, it can trigger recursive events. DisableEventFiring() before the update and EnableEventFiring() after prevents this recursion. This is a standard pattern in SharePoint event receivers. The order matters - disable first, then re-enable after.

Multiple choice technology
  1. Normalizer

  2. XML Target Definition

  3. Both option A and B

  4. All transformations can be used

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Mapplets in Informatica PowerCenter have specific restrictions on which transformations can be included within them. Both Normalizer transformations and XML Target Definitions cannot be used in mapplets due to their complex processing requirements and how they interact with the mapping pipeline. Option D incorrectly claims all transformations are supported, which is not the case.

Multiple choice technology web technology
  1. applicationScope

  2. event

  3. request

  4. execution

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ZK implicit objects include applicationScope, session, execution, desktop, page, component, self, event, native, spaceOwner, spaceController, paramValues, param, and attributes. The 'request' object is a servlet/JSP implicit object, not a ZK-specific implicit object. ZK provides its own abstraction layer through the execution and desktop objects instead of directly exposing the request object.