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. 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.

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. So, this answer is true.

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, not in the PreparedStatement interface and it submits a batch of commands to the database for execution and if all commands execute successfully, it returns an array of update counts. So, this answer is false.

Multiple choice
  1. getColumnClassName(int column)

  2. getScale(int column)

  3. isCaseSensitive(int column)

  4. getColumnSize(int column)

  5. isSearchable(int column)

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

This is the correct answer because there is no method named getColumnSize(int column) in ResultSetMetaData interface. The correct method name is getColumnDisplaySize(int column) which indicates the designated column's normal maximum width in characters.

Multiple choice
  1. getConnection(String url, String user, String password)

  2. deregisterDriver(Driver driver)

  3. getLoginTimeout()

  4. registerDriver(Driver driver)

  5. getLog()

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

This is the correct answer because there is no method named getLog() in DriverManager class. The correct method is getLogWriter() which retrieves the log writer.

Multiple choice
  1. isSigned(int param)

  2. isNullable(int param)

  3. getParameterCount()

  4. getParameterName(int param)

  5. getParameterType(int param)

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

This is the correct choice because there is no method named getParameterName(int param) in ParameterMetaData interface. The correct method is getParameterTypeName(int param) which retrieves the designated parameter's database-specific type name.

Multiple choice
  1. getTime()

  2. Time()

  3. getMilliseconds()

  4. getTimeInMilliseconds()

  5. Milliseconds()

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

This is the correct answer because getTime() method is defined in the TimeStamp class in Java and it returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Timestamp object.

Multiple choice
  1. allProceduresAreCallable()

  2. allTablesAreSelectable()

  3. autoCommitFailureClosesAllResultSets()

  4. dataDefinitionCausesTransactionCommit()

  5. allTablesSelected()

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

This is the correct choice because there is no method named allTablesSelected() in DatabaseMetaData. The correct method is allTablesAreSelectable() and it retrieves whether the current user can call all the procedures returned by the method getProcedures.

Multiple choice
  1. isWritable(int column)

  2. isReadable(int column)

  3. getColumnsName(int column)

  4. getColumnsCount()

  5. getSchema(int column)

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

This is the correct choice because isWritable(int column) is defined in the ResultSetMetaData interface and it indicates whether it is possible for a write on the designated column to succeed.