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
-
Event Source
-
Event Object
-
Event Listener
-
None of these
C
Correct answer
Explanation
This is an object, which is notified when an event occurs.
-
WindowListener
-
KeyListener
-
TextListener
-
ActionListener
C
Correct answer
Explanation
This interface in event listener interface defines one method to recognize when a text value changes.
-
getFontName()
-
getName()
-
getStyle()
-
getFamily()
D
Correct answer
Explanation
This method of Font class returns the name of the font family to which the invoking font belongs.
-
getItem()
-
getItemSelectable()
-
getStateChange()
-
none of these
B
Correct answer
Explanation
getItemSelectable() method can be used to obtain a reference to the ItemSelectable object that generate an event.
-
Adapter classes
-
Inner classes
-
Anonymous classes
-
Window classes
A
Correct answer
Explanation
Java Programming language provide Adapter classes that implement the corresponding listener interface containing more than one method.
-
getConnection()
-
createStatement()
-
executeQuery()
-
getQuery()
A
Correct answer
Explanation
The connection object is initialized using the getConnection() method.
-
translatePoint()
-
getClickCount()
-
isPopupTrigger()
-
getitem()
B
Correct answer
Explanation
getClickCount() method of MouseEvent obtains the number of mouse clicks for the event
-
CONNECT
-
DISCONNECT
-
RECEIVE
-
None of these
B
Correct answer
Explanation
This primitive is used to terminate a connection with the server.
-
getColumnClassName(int column)
-
getScale(int column)
-
isCaseSensitive(int column)
-
getColumnSize(int column)
-
isSearchable(int column)
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.
-
allProceduresAreCallable()
-
allTablesAreSelectable()
-
autoCommitFailureClosesAllResultSets()
-
dataDefinitionCausesTransactionCommit()
-
allTablesSelected()
E
Correct answer
Explanation
This is the correct option 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 or not.
-
getMaxTableLength()
-
getMaxTables()
-
getMaxCharLiteralLength()
-
getMaxUserLength()
-
getSchema()
C
Correct answer
Explanation
This is the correct answer because getMaxCharLiteralLength() is defined in the DatabaseMetaData interface and it retrieves the maximum number of characters the database allows for a character literal.
-
cancelRowUpdates()
-
deleteRow()
-
clearWarnings()
-
deleteColumn()
-
absolute(int row)
D
Correct answer
Explanation
This is the correct option because there is no method named deleteColumn() defined in ResultSet interface.
-
getTime()
-
Time()
-
getMilliseconds()
-
getTimeInMilliseconds()
-
Milliseconds()
A
Correct answer
Explanation
This is the correct option 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.
B
Correct answer
Explanation
This is the correct answer because there are 9 methods defined in the Date class. These are:
1) getHours()
2) getMinutes()
3) getSeconds()
4) setHours(int i)
5) setMinutes(int i)
6) setSeconds(int i)
7) setTime(long date)
8) toString():
9) valueOf(String s)
-
isReadOnly()
-
isCurrency(int column)
-
isDefinitelyWritable(int column)
-
isWritable(int column)
-
isReadOnly(int Column)
A
Correct answer
Explanation
This is the correct option because isReadOnly() method is defined in DatabaseMetaData. It retrieves whether this database is in read-only mode or not.