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. getPercentComplete()

  2. setBorderPainted(boolean)

  3. setPaintedBorder(boolean)

  4. isStringPainted(boolean)

  5. setMinimum(int)

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

This the correct choice because there is no method name setPaintedBorder() in JProgressBar class. The correct method is setBorderPainted which Set the progress bar with a border. So, this answer is true.

Multiple choice
  1. replace(char , char)

  2. replaceAll(String , String)

  3. append(String)

  4. Both 1 and 2

  5. All of the above

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

This is the correct answer. Because the String class objects are immutable i.e once the object of the String class is created its contents cannot be changed. So, we cannot append new characters or string in the old string. So, this is the correct answer.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

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

This is the correct answer, there are four constructors of WeakHashMap in java. These are: 1) WeakHashMap(): Constructs a new, empty WeakHashMap with the default initial capacity (16) and load factor (0.75). 2) WeakHashMap(int initialCapacity):-Constructs a new, empty WeakHashMap with the given initial capacity and the default load factor (0.75). 3) WeakHashMap(int initialCapacity, float loadFactor):-Constructs a new, empty WeakHashMap with the given initial capacity and the given load factor. 4) WeakHashMap(Map m): Constructs a new WeakHashMap with the same mappings as the specified map. So, this is the correct answer.

Multiple choice
  1. setTextVerticalPosition(int textPosition)

  2. setSelectedRolloverIcon(Icon rolloverSelectedIcon)

  3. setTextHorizontalPosition(int textPosition)

  4. setDisplayedMnemonicIndex(int index)

  5. setTextGap(int iconTextGap)

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

This is the correct choice because setDisplayedMnemonicIndex(int index)Method Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic and this method is present in AbstractButton class. So, this answer is correct.

Multiple choice
  1. setRolloverEnabled(boolean)

  2. setPressedIcon(Icon)

  3. setDisabledIcon(Icon)

  4. setSelectedIcon(Icon)

  5. setSelectedRolloverIcon(Icon)

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

This is the correct answer because there is no method named setSelectedRolloverIcon(Icon). The correct method name is setRolloverSelectedIcon(Icon), this method lets you specify the rollover icon when the button is selected. This is useful for two-state buttons such as toggle buttons. So, this is a correct choice.