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
-
Collection
-
RandomAccess
-
Comparator
-
Enumeration
-
All of the above
E
Correct answer
Explanation
Yes, all of the above interfaces are defined by the java.util package.
-
It returns a value true or false.
-
It returns always a true value.
-
It does not return any value.
-
There is no such method in AWT.
-
None of these
A
Correct answer
Explanation
This is true as this method returns a Boolean value according to the condition that whether the window is resizable or not.
-
JButton class can associate with the icon or string with the button.
-
JApplet class supports various panes.
-
JCheckBox is a concrete implementation of AbstractButton.
-
All of the above
-
Only (1) and (2)
D
Correct answer
Explanation
Yes, all the above are true statements.
-
public boolean containsKey(Object key)
-
public Set keySet()
-
public Set entrySet()
-
public Object get(Object key)
-
none of these
A
Correct answer
Explanation
Yes, this method is used to search the specified key from the map.
-
Object clone()
-
void clear()
-
void add(int index, Object element)
-
boolean add(Object o)
-
None of these
E
Correct answer
Explanation
All are the methods of Vector class in java collection framework.
-
TreeSet
-
TreeMap
-
ArrayList
-
Set
-
None of these
C
Correct answer
Explanation
It allows duplicate values.
-
TreeMap maintains the ascending order of the elements.
-
TreeMap does not allow null keys.
-
HashMap allows null key.
-
There is no order of elements in the HashMap class.
-
All of the above
E
Correct answer
Explanation
All the statements are true.
-
Clone()
-
toString()
-
Finalize()
-
valueOf()
-
Equals()
D
Correct answer
Explanation
This is not a method of Object class. This is a method of String class.
-
Garbage collection can be forced explicitly.
-
Garbage collection is done by JVM.
-
User can request JVM for Garbage collection explicitly calling gc() method.
-
Both 1 and 2 are true.
-
Both 2 and 3 are true.
E
Correct answer
Explanation
Option 2 and 3 both are true. Hence this option is the correct answer.
-
this
-
3name
-
_name1
-
#name1
-
None of the above
C
Correct answer
Explanation
Identifier can start with _ (under score) or $ (dollar) and can continue with alphabets and digits.
-
StringBuilder class is faster than StringBuffer class.
-
StringBuilder is thread safe.
-
StringBuffer str=new StringBuffer("hello");
//creates an immutable string object "str" which contains "hello"
-
StringBuilder is synchronized.
-
None of the above statements is true
A
Correct answer
Explanation
StringBuilder is not synchronized , where as StringBuffer is synchronized. Hence StringBuilder is faster than String Buffer.
-
IllegalArgumentException
-
JCheckBox
-
IllegalMonitorStateException
-
JComboBox
-
JRadioButton
D
Correct answer
Explanation
This class in Java is a swing version that is used to encapsulate a combo box in an applet program.
-
Start
-
Restart
-
Reload
-
Stop
-
Clone
E
Correct answer
Explanation
This option is used to duplicate the current applet in order to create another AppletViewer instance.
-
Restart
-
Stop
-
Quit
-
-classpath
-
None of these
C
Correct answer
Explanation
This option closes the AppletViewer window and terminates the applet.
-
Save
-
Reload
-
Stop
-
Print
-
None of these
B
Correct answer
Explanation
Reload option reloads the applets with the changes in the .class file applied.