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
-
StringReader
-
PipeReader
-
InputReader
-
Both 1 and 2
-
Both 1 and 3
C
Correct answer
Explanation
There is no subclass of Reader class named InputReader. The correct name is InputStreamReader used for reading a character stream. So this is the correct answer according to the question.
-
CharWriter
-
StringWriter
-
BufferedWriter
-
Both 1 and 2
-
Both 1 and 3
A
Correct answer
Explanation
This is the correct answer. There is no Subclass named charWriter. The correct name is CharArrayWriter which is used for writing to a char array. So this is the correct answer according to the question.
-
getPath()
-
getName()
-
length()
-
both 1 &and 2
-
all of these
E
Correct answer
Explanation
All of the given methods are defined in the File class. So this is the correct answer.
-
read(byte[ ] b)
-
mark(int limit)
-
read()
-
both 1 and 3
-
all of these
E
Correct answer
Explanation
All of the methods are defined in the Input Stream class. So this is the correct choice.
-
mouseEnetered()
-
keyReleased()
-
mouseDragged()
-
Both 1 & 2
-
All of these
E
Correct answer
Explanation
This is correct answer because all of the given methods are valid in java event handling.
-
fillRect()
-
fillCircle()
-
fillOval()
-
fillArc()
-
None of these
B
Correct answer
Explanation
This option is correct because there is no method defined fillCircle() in Graphics class.
-
JRadioButton
-
JCheckBox
-
JComboBox
-
JList
-
JTextField
D
Correct answer
Explanation
This is the answer because JList doesn’t generate an ActionEvent. When we click an item in JList ListSelectionEvent is generated.
-
setLocation(int ,int)
-
setVisible(Boolean)
-
setSize(int , int)
-
setDefaultCloseOperation(int)
-
Pack()
D
Correct answer
Explanation
This function is not defined in the Frame class. This function is defined in JFrame class in Swings. So this method cannot be invoked using the object of Frame class. But can be invoked using the Object of JFrame class.This method specifies the operation when the frame is closed. So the following line would be false. Frame f1 = new frame();f1.setDefaultCloseOperation(int); So, this is the correct answer.
-
FocusEvent
-
ComponentEvent
-
AdjustmentEvent
-
Both 2 and 3
-
None of these
E
Correct answer
Explanation
As all of the given event types are valid in java. So, this option is correct.
-
windowMoved()
-
windowClosing()
-
windowIconified()
-
windowActivated()
-
windowDeiconified()
A
Correct answer
Explanation
If a class implements an interface, then it is necessary for that class to define body to all the methods defined in the interface it is implementing. But windowMoved() method is not present in windowListener interface. So, when a class will implement this interface this method need not be defined in the class. So, this option is correct.
-
Wait()
-
Destroy()
-
Dead()
-
Both 1 and 3
-
Both 1 and 2
D
Correct answer
Explanation
As the reason is explained both methods in option 1 and 3 are not used by the web browser to control the applet. So, this option is correct.
-
IllegalArgumentException
-
NullPointerException
-
IOException
-
IndexOutOfBoundException
-
ArithmeticException
C
Correct answer
Explanation
IOException is not a subclass of RuntimeException class, this class is a Subclass of Exception class. This exception is thrown when invalid inputs/outputs are given. So, this is the correct answer as this is not a subclass of RuntimeException class.
-
Next()
-
nextLine()
-
nextInt()
-
nextChar()
-
nextLong()
D
Correct answer
Explanation
There is no function defined in scanner class to take character input. So, there is no function named nextChar(). Hence, this is the correct answer.
-
Garbage collection reduces the effect of memory management methods.
-
The dealloc method can not be called during GC.
-
The methods like copy and mutable copy messages, copy the value of the object in case GC is enabled.
-
The final method can not be implemented if GC is enabled.
-
Garbage collection is off by default.
D
Correct answer
Explanation
One can implement the final method for some (though not all) of the same cases.
-
The release and retain of the methods are done automatically.
-
The release and retain of the methods are done automatically as well as manually.
-
There is low memory leak.
-
Reference counting works in this approach.
-
It uses the same reference counting system as (Manual Retain-Release) MRR.
B
Correct answer
Explanation
This is false as the manually release and retain of the methods is not possible.