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. addBatch(String sql)

  2. closeOnCompletion()

  3. executeQuery(String sql)

  4. executeBatch()

  5. getResults()

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

There is no method named getResults() in Statement interface. The correct method name is getMoreResults() which moves to this Statement object's next result, returns true if it is a ResultSet object, and implicitly closes any current ResultSet object(s) obtained with the method getResultSet. So, this answer is true.

Multiple choice
  1. 10

  2. 9

  3. 8

  4. 7

  5. 6

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

There are 8 constructors of SQLTimeoutException class in java. These are:- 1) SQLTimeoutException():- Constructs a SQLTimeoutException object 2) SQLTimeoutException(String reason):- Constructs a SQLTimeoutException object with a given reason 3) SQLTimeoutException(String reason, String SQLState):- Constructs a SQLTimeoutException object with a given reason and SQLState 4) SQLTimeoutException(String reason, String SQLState, int vendorCode):- Constructs a SQLTimeoutException object with a given reason, SQLState and vendorCode 5) SQLTimeoutException(String reason, String SQLState, int vendorCode, Throwable cause):- Constructs a SQLTimeoutException object with a given reason, SQLState, vendorCode and cause 6) SQLTimeoutException(String reason, String SQLState, Throwable cause):- Constructs a SQLTimeoutException object with a given reason, SQLState and cause 7) SQLTimeoutException(String reason, Throwable cause):- Constructs a SQLTimeoutException object with a given reason and cause 8) SQLTimeoutException(Throwable cause):- Constructs a SQLTimeoutException object with a given cause So, this is the correct answer.