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. i. is true

  2. ii. is true

  3. iii. is true

  4. iv. is true

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

This answer is correct because Serializable interface is a marker interface and does not have any methods. This interface when implemented, tells the object serializable tools whether the class is serializable or not.

Multiple choice
  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true.

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

The answer is correct.The Reader/Writer class is used when any manipulation needs to be done on characters whereas InputStream/OutputStream class is used when any manipulation needs to be done on bytes.

Multiple choice
  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true

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

This answer is correct. When an object invokes yield() method, the object will be ready to perform the next action and so it will be returned to the ready state. When the object calls sleep() method, it will not execute any further action and so it will not be ready to perform next action.

Multiple choice
  1. i. and iii. are true.

  2. i. and iv. are true

  3. ii. and iii. are true.

  4. ii. and iv. are true.

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

This answer is correct. String Buffer is synchronized or thread-safe and String Builder has higher performance compared to String Buffer.

Multiple choice
  1. i. and iv. are true

  2. i. and iii. are true

  3. ii. and iii. are true

  4. ii. and iv. are true

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

This answer is correct. NoSuchMethodException is caused when the method does not exist. NoSuchMethodException is a Checked Exception.

Multiple choice
  1. getClass()

  2. notify()

  3. notify all()

  4. hashCode()

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

This answer is correct. GetClass(), notify(), notify all() and wait() methods in Object class are declared as final. All other methods can be overridden. HashCode() can be overridden in any class.

Multiple choice
  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true

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

This answer is correct. ClassNotFoundException is caused when the class is not found and it is a checked exception.

Multiple choice
  1. addBatch()

  2. executeQuery()

  3. executeBatch()

  4. execute()

  5. getMetaData()

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

executeBatch() method is present in the Statement interface and not in PreparedStatement interface and it submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. So, this answer is true.

Multiple choice
  1. isCloseOnInsertion()

  2. isCloseOnCompletion()

  3. isCloseOnDeletion()

  4. isCloseAfterUpdate()

  5. isCloseAfterInsertion()

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

isCloseOnCompletion() method is present in the Statement interface. This method returns a value indicating whether this statement will be closed when all its dependent result sets are closed or not. So, this answer is correct.

Multiple choice
  1. 10

  2. 9

  3. 8

  4. 7

  5. 6

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

There are 10 methods present in the Time class in java. These are:- 1) getDate() 2) getDay() 3) getMonth() 4) getYear() 5) setDate(int i) 6) setMonth(int i) 7) setTime(int i) 8) setYear(int i) 9) toString():- Formats a time in JDBC time escape format 10) valueOf(String s):- Converts a string in JDBC time escape format to a Time value So, this is the correct answer.