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 platforms and products
  1. onStart()

  2. onResume()

  3. onCreate()

  4. None of above

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

onCreate() is the first method called when an activity is created. It's where you initialize your activity, set up the UI with setContentView(), bind data, and create any objects or resources the activity will need. This method is called once per activity instance, unlike onStart() or onResume() which can be called multiple times.

Multiple choice technology platforms and products
  1. onResume(), onStop()

  2. onStart(), onStop()

  3. onStart(), onDestroy()

  4. onResume(), onDestroy()

  5. None of above

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

In Android activity lifecycle, onStart() indicates when the activity becomes visible to the user, and onStop() is called when it's no longer visible. Resources needed to display the activity to the user (such as views and UI elements) should be initialized in onStart() and released in onStop(). onResume() and onPause() are for foreground/interactive state, not visibility.

Multiple choice technology platforms and products
  1. onCreate()

  2. onResume()

  3. onStart()

  4. None of above

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

The onCreate() method receives a savedInstanceState Bundle parameter that contains the activity's previously saved state. This state is captured in onSaveInstanceState() when the activity may be killed by the system. onResume() and onStart() do not receive this Bundle parameter.

Multiple choice technology testing
  1. Recovery scenerio

  2. Recovery types

  3. Exception handler

  4. onexit

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

QTP handles exceptions using Recovery Scenarios, which allow you to define trigger events, recovery operations, and post-recovery test run options. This is QTP's built-in mechanism for handling unexpected events, errors, or application crashes during test execution. Option C (Exception handler) is a general programming term but not QTP-specific.

Multiple choice technology testing
  1. wait

  2. waitproperty

  3. sleep

  4. getproperty

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

The waitproperty method is used for synchronization in QTP. It pauses test execution until a specified object property achieves a certain value or times out. This is the preferred synchronization method over static waits like wait() or sleep() because it waits dynamically based on application state rather than fixed time intervals.

Multiple choice technology testing
  1. Gettext

  2. Getvisibletext

  3. GetROProperty

  4. All the above

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

All the above is correct because different methods are used in different contexts to retrieve text values. GetROProperty retrieves runtime object properties including text, GetVisibleText captures visible text on screen, and GetText is used for retrieving text from specific objects. The appropriate method depends on the testing scenario.

Multiple choice technology programming languages
  1. When browser is closed

  2. When the page reloads as well.

  3. Only when you navigate out of the page.

  4. All Of the Above

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

The onunload event is triggered when the document is being unloaded from the browser. This includes closing the browser window, reloading the current page, or navigating to a new webpage. Since all these actions trigger the unload sequence, 'All Of the Above' is the correct choice.

Multiple choice technology operating systems
  1. void onCreate(Bundle savedInstanceState)

  2. void onStart()

  3. void onResume()

  4. void onDestroy()

  5. void onExit

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

Android's Activity lifecycle includes standard callback methods such as onCreate, onStart, onResume, and onDestroy. There is no void onExit method in Java's Android Activity lifecycle class, making it an invalid method name, whereas the others are all standard, valid callbacks.

Multiple choice technology operating systems
  1. ContentResolver cr = getContentResolver();

  2. ContentResolver cr = getContentResolver(cr);

  3. ContentResolver cr = getContentResolver(content);

  4. ContentResolver cr = getContentResolver(void);

  5. ContentResolver cr = getContentResolver(context);

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

getContentResolver() is the correct method to obtain a ContentResolver instance within an Activity or other application component. It takes no parameters and returns a ContentResolver object that can interact with content providers. The other options incorrectly pass parameters (cr, content, void, context) to this method.

Multiple choice technology operating systems
  1. mp.initialize();

  2. mp.start();

  3. mp.do();

  4. mp.run();

  5. mp.process();

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

In Android, the MediaPlayer class uses the start() method to begin or resume playback of audio/video streams. The other listed options like initialize, do, run, or process are not standard methods of the Android MediaPlayer API for initiating media playback.

Multiple choice technology
  1. String str =”cocoa”;

  2. NSString *str =@”cocoa”;

  3. NSString str= “cocoa”;

  4. NSString* str=@”cocoa”;

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

In Objective-C, strings are declared using NSString class with the @ symbol before the string literal to indicate it's an Objective-C string object (not a C string). The correct syntax is NSString *str = @"cocoa"; where the asterisk denotes a pointer to the object, and the @ symbol creates an NSString object from the literal.

Multiple choice technology
  1. -(void) mouseUp: (NSEvent *) theEvent;

  2. -(void) mouseDown: (NSEvent *) theEvent;

  3. -(void) mouseDragged: (NSEvent *) theEvent;

  4. -(void) mouseClick: (NSEvent *) theEvent;

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

The standard mouse event methods in Cocoa are mouseUp, mouseDown, and mouseDragged. There is no 'mouseClick' method in the standard mouse event protocol - click events are typically derived from up/down combinations.