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
-
onCreate
-
doAfterCompose
-
onClick
-
service
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.
-
document.appletname.getGridObject ().getCellValue (row, column)
-
document.appletname.getValue (column, row)
-
document.appletname.getValue (row, column)
-
none of the above
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.
-
When the developer packages the application
-
When the application loads
-
The first time it is called
-
When the application is installed
-
Each time it is called
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.
-
GetVisibleText
-
SetROProperty
-
GetROProperty
-
GetTOProperty
-
GetPropertyValue
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.
-
Low-Level
-
Standard
-
Text Area
-
Bitmap
-
Text
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.
-
Session.contains() method to determine if an instance belongs to the session cache
-
Session.contains() method to determine if an instance belongs to the data base
-
Both are correct
-
None of the above
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.
-
Remove the object and its collections from the first level cache
-
Remove the object and its collections from the second level cache
-
Remove the object and its collections from the data base
-
None of the above
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.
-
ListResultSet
-
ResultSet
-
ScrollableResultSet
-
ScrollableResult
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.
-
refresh();
-
flush();
-
fetch();
-
load()
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.
-
str.Substring(str.Length);
-
str.Substring(str.Length - 1);
-
str.LastChar();
-
str.RightChar();
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.
-
DateTime.Now.PreviousMonth;
-
DateTime.Now.CurrentMonth - 1;
-
DateTime.Now.AddMonths(-1);
-
DateTime.Now.AddMonths(1);
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.
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.
B
Correct answer
Explanation
The foreground lifetime of an activity occurs between the call to onResume() and the corresponding call to onPause(), during which the activity is in the foreground and interacting with the user.
-
onPause()
-
onResume()
-
onRestart()
-
onStart()
-
None of above
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.
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.