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 web technology
  1. onCreate

  2. doAfterCompose

  3. onClick

  4. service

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

The onCreate method is executed first when a ZK page loads. It is called immediately after a component is created and before any other lifecycle events. doAfterCompose is called for MVC composers after components are created, onClick is an event handler triggered later by user action, and 'service' is not a standard ZK lifecycle method. onCreate fires first in the component initialization sequence.

Multiple choice technology
  1. document.appletname.getGridObject ().getCellValue (row, column)

  2. document.appletname.getValue (column, row)

  3. document.appletname.getValue (row, column)

  4. none of the above

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

iCommand applets expose values through the getValue(column, row) method in JavaScript. The parameter order is column first, then row index - this is a specific API convention in MII applets. Option B shows the correct syntax.

Multiple choice technology web 2.0
  1. When the developer packages the application

  2. When the application loads

  3. The first time it is called

  4. When the application is installed

  5. Each time it is called

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

JIT (Just-In-Time) compilation occurs on-demand - when a method is first invoked at runtime. The method is converted from IL to native code immediately before its first execution, then cached for subsequent calls. This is the core 'just-in-time' concept - compiling right when it's needed.

Multiple choice technology testing
  1. GetVisibleText

  2. SetROProperty

  3. GetROProperty

  4. GetTOProperty

  5. GetPropertyValue

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

GetROProperty retrieves the current runtime property value of an object during test execution. 'RO' stands for Runtime Object - this method gets the actual property value from the application being tested. GetTOProperty retrieves Test Object properties from the repository (the expected values), not current runtime values. SetROProperty doesn't exist for retrieval. GetVisibleText and GetPropertyValue are not standard QTP methods for this purpose.

Multiple choice technology testing
  1. Low-Level

  2. Standard

  3. Text Area

  4. Bitmap

  5. Text

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

A Standard Checkpoint in QTP/UFT is specifically designed to verify the properties and values of objects in an application. Other checkpoints serve different purposes: Text checkpoints check text strings, Bitmap checkpoints compare pixel images, and Low-Level checkpoints record raw coordinate inputs rather than object properties.

Multiple choice technology programming languages
  1. Session.contains() method to determine if an instance belongs to the session cache

  2. Session.contains() method to determine if an instance belongs to the data base

  3. Both are correct

  4. None of the above

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

Session.contains() checks if a specific entity instance is currently managed within the persistence context (session cache). It does not query the database to determine if the record exists there. Therefore, the first statement is correct, while the second is incorrect because it misinterprets the method's scope.

Multiple choice technology programming languages
  1. Remove the object and its collections from the first level cache

  2. Remove the object and its collections from the second level cache

  3. Remove the object and its collections from the data base

  4. None of the above

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

The session.evict() method removes an object and its associated collections from the first-level cache (session cache). This detaches the object from the session, meaning subsequent changes won't be tracked. It does not affect the second-level cache or delete from the database.

Multiple choice technology programming languages
  1. ListResultSet

  2. ResultSet

  3. ScrollableResultSet

  4. ScrollableResult

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

The scroll() method on Hibernate's Query interface returns an instance of ScrollableResults, which acts as a cursor to scroll through the query results. The option ScrollableResult contains a typographical error (missing the trailing 's'), but represents the intended interface type, while the other choices are incorrect.

Multiple choice technology programming languages
  1. refresh();

  2. flush();

  3. fetch();

  4. load()

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

The refresh() method re-loads the object and all its collections from the database, overwriting any changes made to the persistent object. This is particularly useful when database triggers modify properties after the initial load. Unlike flush() which writes changes to the database, refresh() synchronizes the in-memory object with the database state.

Multiple choice technology web technology
  1. str.Substring(str.Length);

  2. str.Substring(str.Length - 1);

  3. str.LastChar();

  4. str.RightChar();

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

To get the rightmost character of a string, you use Substring(str.Length - 1, 1) or Substring(str.Length - 1). This starts from the last character position. Option A with str.Length would cause an ArgumentOutOfRangeException, and options C and D are not valid string methods.

Multiple choice technology web technology
  1. DateTime.Now.PreviousMonth;

  2. DateTime.Now.CurrentMonth - 1;

  3. DateTime.Now.AddMonths(-1);

  4. DateTime.Now.AddMonths(1);

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

The AddMonths method is the correct way to perform date arithmetic in C#. Using a negative parameter (-1) subtracts months from the current date. DateTime.Now.AddMonths(1) would give next month, and there are no PreviousMonth or CurrentMonth properties on DateTime.

Multiple choice technology platforms and products
  1. True

  2. False

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

The visible lifetime of an activity extends from onStart() to the corresponding onStop() call, not onPause(). The activity is visible to the user in the onStart()-onStop() window, while onPause() indicates partial obscuration (activity is still visible but not in focus). The visible lifecycle can repeat multiple times as the user navigates away and back.

Multiple choice technology platforms and products
  1. onPause()

  2. onResume()

  3. onRestart()

  4. onStart()

  5. None of above

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

In the Android Activity lifecycle, onResume() is called just before the activity starts interacting with the user, bringing it to the top of the activity stack and receiving user input.

Multiple choice technology platforms and products
  1. True

  2. False

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

True. The onStart() and onStop() methods can be called multiple times during an activity's lifetime. Each time the activity becomes visible to the user, onStart() is called, and when it's no longer visible, onStop() is called. This cycle can repeat many times - for example, when the user navigates to other apps and returns, or when a dialog appears and disappears.