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
  1. onCreate(), onStart(), onResume(), onPause(), onStop().

  2. onCreate(), onStart(), onResume(), onStop(), onDestroy().

  3. onCreate(), onResume(), onPause(), onStop(), nDestroy().

  4. onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy().

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

There are six functions are used in Activity Life Cycle of Android:

onCreate()
onStart()
onResume()
onPause()
onStop() onDestroy().

Multiple choice
  1. This allows us to send message to be processed immediately only.

  2. This allows us to send messages can be processed at some time in the future only.

  3. This allows us to send messages which can be processed immediately or scheduled for processing at some time in the future.

  4. None of the above

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

A handler class allows you to send messages which are to be processed by the handler at some other time or immediately.

Multiple choice
  1. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDialog()
    .build());
    
  2. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDeath()
    .build());
    
  3. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDialog()
    );
    
  4. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyDialog()
    .build());
    
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Simple StrictMode declaration that detects all types of network and disk I/O:

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
 .detectAll()
 .penaltyLog()
 .penaltyDialog().build());
Multiple choice
  1. Public Boolean isTimerRunn(){
         Return mHandler.hasMessages(0);
    }
    
  2. Private Boolean isTimerRunn(){
         Return mHandler.hasMessages(0);
    }
    
  3. Private Boolean is TimerRunn(){
         Return mHandler.hasMessages(0);
    }
    
  4. Private Boolean isTimerRunn(){
         Return mHandler.queueMessages(0);
    }
    
Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The method that checks for messages in the message queue can be defined as follows:

Private Boolean isTimerRunn() {
 Return mHandler.hasMessages(0);
}
Multiple choice
  1. Private void startTimer(){
       mSt=System.currentTimeMillis();
       mHandler.removeMessages(0);
       mHandler.sendEmptyMessage(0);
    }
    
  2. Private void startTimer(){
       mSt=System.currentTime();
       mHandler.removeMessages(0);
       mHandler.sendEmptyMessage(0);
    }
    
  3. Private void startTimer(){
       mSt=System.currentTimeMillis();
       mHandler.removeMessage(0);
       mHandler.sendEmptyMessage(0);
    }
    
  4. Private void startTimer(){
       mSt=System.currentTimeMillis();
       mHandler.removeMessages(0);
       mHandler.sendEmptyMessages(0);
    }
    
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The code for recording the current system time and sending a message to the handler, starting the timer and removing any existing messages before sending the next one is as follows:

Private void startTimer() {
 mSt = System.currentTimeMillis();
 mHandler.removeMessages(0);
 mHandler.sendEmptyMessage(0);
}
Multiple choice
  1. Point

  2. Refresh

  3. Pset

  4. Open

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

In Visual Basic, forms have built-in methods like Refresh, Show, Hide, and Move. Point and Pset are graphics methods used for drawing on forms or picture boxes. Open is a file I/O statement used to access files, not a forms method. Therefore, Open is not a forms method.

Multiple choice
  1. The instance of the Command object can either be to create or optional.

  2. Write method is executed to provide the query specific results in the database.

  3. DataReader provides a series of methods that allow access to column values in their native data types.

  4. The DataReader cannot maintain the execution flow at each level at one stage.

  5. It manages the execution only at one level.

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

This is correct as the underlying data type is known, reducing the amount of type conversion required when retrieving the column value.

Multiple choice
  1. It specifies that the streaming objects are now closed after the operation is performed by the client.

  2. It shows that an error occurred in a Stream, XmlReader or TextReader object during a streaming operation.

  3. It specifies that current state of the connection is closed. ExecuteReader requires an open SqlConnection.

  4. It shows that a SqlDbType other than Binary or VarBinary was used when Value was set to Stream.

  5. It shows the limited memory capacity in the application.

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

This is correct as the Stream, XmlReader or TextReader object was closed during a streaming operation.