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
-
wasNull()
-
getTableName(int column)
-
isCaseSensitive(int column)
-
getColumnType(int column)
-
getColumnName(int column)
A
Correct answer
Explanation
This is the correct choice. wasNull() method is defined in the ResultSet interface.
-
getWarnings()
-
getResultSet()
-
getStatement()
-
getResultSetType()
-
isClosed()
C
Correct answer
Explanation
This is the correct choice. getstatement() method is not defined in the Statement interface.
-
isWritable(int column)
-
isSearchable(int column)
-
isNullable(int column)
-
isAutoIncrement(int column)
-
isClosed()
E
Correct answer
Explanation
There is no method named isClosed() present in the ResultSetMetaData interface in Java.
-
void printStackTrace( )
-
String getMessage( )
-
String toString( )
-
void printStackTrace(PrintWriter stream)
-
String getLocalizedMessage( )
B
Correct answer
Explanation
Yes, this method returns a description of the exception.
-
Math
-
Number
-
Thread
-
System
-
Date
E
Correct answer
Explanation
This class is defined under java.util package.
-
There should be a catch block to execute finally clause.
-
Finally block is executed only when there is an exception in a program.
-
JVM always executes finally block before terminating the program.
-
Finally block can be put before catch block.
-
Finally block can handle the exception in the code.
C
Correct answer
Explanation
JVM executes finally block just before terminating the program to close the connection and resources.
-
object next( )
-
boolean hasNext( )
-
void remove( )
-
boolean hasPrevious( )
-
Both (3) and (4)
D
Correct answer
Explanation
This is the method of ListIterator interface and returns true if there is a previous element. Otherwise, it returns false.
-
Comparator comparator( )
-
SortedMap subMap(Object start, Object end)
-
SortedMap tailMap(Object start)
-
SortedMap headMap(Object end)
-
Set entrySet( )
E
Correct answer
Explanation
This is the method of Map interface.
-
charAt()
-
toCharArray()
-
getChars()
-
getBytes()
-
Both (1) and (2)
B
Correct answer
Explanation
This method converts all the characters in a String object into a character array.
-
This method is called by the browser to unload the applet.
-
This method is called by the browser, when applet is first loaded.
-
This method is called by the browser, when an applet should start or resume its execution.
-
This method is called by the browser to suspend execution of the applet and if it will be restarted again when browser returns that page by start() method.
-
This method returns the URL associated with that applet.
D
Correct answer
Explanation
stop() method is called for that.
-
start() method starts a thread by calling its run method.
-
run() is an entry point for the thread.
-
sleep() method temporarily suspends a currently executing thread.
-
isAlive() method determines if a thread is still running.
-
join() method waits for a thread to terminate.
C
Correct answer
Explanation
This is a false statement because sleep() method causes the currently executing thread to sleep for the specified number of milliseconds.
-
IllegalArgumentException
-
InterruptedException
-
IllegalMonitorStateException
-
IllegalStateException
-
UnsupportedOperationException
B
Correct answer
Explanation
sleep() method throws this exception.
-
This class gives buffered input character stream.
-
This is an input stream that reads from a character array.
-
This is an input stream that translates bytes to characters.
-
This is an input stream that counts lines.
-
This is an output stream that translates characters to bytes.
C
Correct answer
Explanation
Its a true statement about InputStreamReader class.
-
insert()
-
delete()
-
replace()
-
trim()
-
charAt()
D
Correct answer
Explanation
trim() method is used to remove the blank spaces from both the ends of the invoking string.
-
Hashtable is synchronised.
-
A list can contain duplicate elements but a set cannot.
-
HashMap is used for non-threaded applications.
-
ArrayList dynamically increases or decreases in size.
-
ArrayList is synchronised.
E
Correct answer
Explanation
ArrayList is not synchronised.