Computer Knowledge

Java Core Classes and Threads

1,473 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. Destroy this thread, without any clean-up

  2. Destroy this thread, with clean-up

  3. Destroy all threads, without any clean-up

  4. Destroy all threads, with clean-up

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

The destroy() method of thread class destroys this thread, without any clean-up.

Multiple choice
  1. ArrayIndexOutOfBoundsException

  2. ArrayIndexOutOfBoundsExceptions

  3. ArrayIndexOutOfBoundException

  4. ArrayOutOfBoundsException

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

The ArrayIndexOutOfBoundsException occurs if one is trying to access an element of array with an index that is larger than the range. For example: int Num[]={0,2,3}; Num[5]=0; /This statement throws the exception/

Multiple choice
  1. A method is called on that object

  2. A member variable is set for that object

  3. A text string is assigned to the object.

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

In object-oriented programming, sending a message to an object is the mechanism by which an operation is invoked. This results in the execution of a method defined within that object's class.

Multiple choice
  1. must be initialized

  2. cannot be deleted

  3. cannot be changed

  4. None of the above

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

Immutability in Java means that once a String object is created, its internal state (the sequence of characters) cannot be changed.

Multiple choice
  1. the Java Virtual Machine

  2. code in a try block

  3. calls from a try block to other methods

  4. All of the above

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

Exceptions can be thrown by the JVM (e.g., NullPointerException), by explicit throw statements in code, or by methods called within a try block.