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

  2. NullPointerException

  3. IOException

  4. IndexOutOfBoundException

  5. ArithmeticException

Reveal answer Fill a bubble to check yourself
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 input/output are given. So, this is the correct answer, as this is not a subclass of RuntimeException class.

Multiple choice
    • 1
  1. 11

  2. 6

  3. Compiler error : method lastIndexOf() not declared.

  4. Compiler error : parameters to method not sufficient.

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

lastIndexOf(String s , index i) method return the last occurrence of string s before the from index. Return -1 if string not found. So, here the string to find is “Java” before the index 5, which means before the character m. But, string “java” is not present before the index 5, i.e. character m. So, it will return -1.

Multiple choice
  1. setLocation(int, int)

  2. setVisible(Boolean)

  3. setSize(int, int)

  4. setSize(int, int)

  5. Pack()

Reveal answer Fill a bubble to check yourself
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. Hence, this would be false. Frame f1 = new frame();f1.setDefaultCloseOperation(int); so this is the correct answer.

Multiple choice
  1. windowMoved()

  2. windowClosing()

  3. windowIconified()

  4. windowActivated()

  5. windowDeiconified()

Reveal answer Fill a bubble to check yourself
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 to be define in the class. So, this option is correct.