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. str1.equals(str2);

  2. str1.equalsIgnoreCase(str2)

  3. str1.equalignoreCase(str2)

  4. str1.equalsIgnorecase(str2)

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

The method equlaIgnoreCase() is used to compare the given string to another string by ignoring the case consideration. Hence, to compare str1 and str2, the statement will be as follows: str1.equalsIgnorecase(str2);

Multiple choice
  1. str1.indexOf(int ch,int from Index)

  2. str1.indexOf(String str)

  3. str.indexOf(string str1)

  4. str.indexOf(String str1)

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

The method indexOf() is used to get the index within the given string “str” at the first occurrence of the specified substring “str1”. Hence, the statement will be str.indexOf(String str1);

Multiple choice
  1. Integer.parseInt(String str)

  2. Integer.convertInt(String str)

  3. Integer.valueOf(String str)

  4. Integer.toInteger(String str)

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

This answer is correct. To convert a String to a primitive integer, static method parseInt(String str) is executed. This will take the String variable and convert to primitive integer

Multiple choice
  1. hashCode()

  2. equals()

  3. clone()

  4. toString()

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

This answer is correct. Annotation interface overrides only three methods hashCode(), toString() and equals() methods. All the methods in Object class other than hashCode(), toString() and equals() are not overridden by the Annotation interface.

Multiple choice
  1. 1 and 2

  2. 2 and 3

  3. 3 and 4

  4. 1 and 3

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

Statements (3) and (4) are correct. Statements (1) and (2) are incorrect because hashCode() and equals() can't be overridden.

Multiple choice
  1. i. and iv. are correct

  2. i. and iii. are correct

  3. ii. and iii. are correct

  4. ii. and iv. are correct

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

The dynamic dispatch process is a process which is applicable when  a call to the overridden method is resolved at runtime rather than at compile time. This will be used as part of polymorphism concept. In the dynamic dispatch process, a reference variable calls the overridden method of the superclass but not the subclass because it doesn't know anything about subclass.