0

Java Collections and GUI

Description: Concept Based Questions
Number of Questions: 15
Created by:
Tags: Concept Based Questions Java Basics
Attempted 0/15 Correct 0 Score 0

Which of the methods are not present in the JLabel class in java?

  1. getDisplayedMnemonic()

  2. getDisabledIcon()

  3. getIconTextGap()

  4. All of the above

  5. Both 1 and 2


Correct Option: D
Explanation:

As explained that all the methods are present in the JLabel class. So, this answer is true.

Which of the following methods are defined in the String class for comparing the Strings?

  1. equals(String s)

  2. compareToIgnoreCase(String s1)

  3. compareTo(String s3)

  4. Both 2 and 3

  5. All of the above


Correct Option: E
Explanation:

As I explained the reason, all of the functions are defined in the String class. So, this is the correct answer.

Which of the following methods are present in AbstaractButton Class in java?

  1. setVerticalAlignment(int alignment)

  2. setMultiClickThreshhold(long threshhold)

  3. setMargin(Insets m)

  4. Both 1 and 3

  5. All of the above


Correct Option: E
Explanation:

As explained all the methods are resent in abstractbutton class, so this answer is correct.

Which of the following methods are invalid in java GUI?

  1. createLoweredBevelBorder()

  2. createRaisedBevelBorder()

  3. createBevelBorder(int, Color, Color)

  4. createMatteBorder(int, int, int, int, Color)

  5. createFilledBorder()


Correct Option: E
Explanation:

This is the correct choice because there is no method named createFiledBorder() in java. So, this answer is correct.

Which of the following methods are not present in JProgressBar class in java?

  1. getPercentComplete()

  2. setBorderPainted(boolean)

  3. setPaintedBorder(boolean)

  4. isStringPainted(boolean)

  5. setMinimum(int)


Correct Option: C
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.

Which of the following methods are present in JComponent class in java?

  1. getComponentCount()

  2. getTopLevelAncestor()

  3. getPane()

  4. Both 1 and 2

  5. All of the above


Correct Option: D
Explanation:

As I explained that both the options 1 and 2 are correct, so this answer is true.

Which of the following methods cannot be used with the object of String class?

  1. replace(char , char)

  2. replaceAll(String , String)

  3. append(String)

  4. Both 1 and 2

  5. All of the above


Correct Option: C
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.

Which of the following methods are present in the JScrollPane class in java?

  1. isWheelScrollingEnabled()

  2. isScrollingWheelEnabled()

  3. getScrollsOnExpand()

  4. Both 1 and 2

  5. Both 1 and 3


Correct Option: E
Explanation:

As I explained both the methods of option 1 and 3 are valid in JScrollPane class. So, this answer is true.

Which of the following methods is/are not present in JComponent class in java?

  1. isShowing()

  2. getLocationOnScreen()

  3. getInsets()

  4. isOpaque()

  5. isCircle()


Correct Option: E
Explanation:

This is the correct choice. There is no method named isCircle() present in JComponenet class in java. So, this is the correct choice.

Which of the following methods are present in the JTabbedPane class?

  1. indexOfTabComponent(Component)

  2. getTabComponentAt(int)

  3. setTabComponentAt(int, Component)

  4. Both 2 and 3

  5. All of these


Correct Option: E
Explanation:

As I explained all the methods are present in the JTabbedPane class. So, this answer is correct.

Which of the following methods are present in JFormattedTextField Class?

  1. getAllowsInvalid()

  2. getOverwriteMode()

  3. setCommitsOnValidEdit(boolean)

  4. Both 1 and 2

  5. All of the above


Correct Option: E
Explanation:

As I explained that all the methods given are present in JFormattedTextField class. So, this answer is true.

Which of the following methods are not present in JComponent class in java?

  1. getComponentGraphics(Graphics g)

  2. isLightweightComponent(Component c)

  3. isPaintingTile()

  4. isPaintingForPrint()

  5. isPrinting()


Correct Option: E
Explanation:

This is the correct answer, there is no method named isPrinting() in JComponent class in java. So, this answer is correct.

How many constructors of WeakHashMap are there in Java collections Framework?

  1. 6

  2. 5

  3. 4

  4. 3

  5. 2


Correct Option: C
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.

Which of the following methods are present in AbstractButton class?

  1. setTextVerticalPosition(int textPosition)

  2. setSelectedRolloverIcon(Icon rolloverSelectedIcon)

  3. setTextHorizontalPosition(int textPosition)

  4. setDisplayedMnemonicIndex(int index)

  5. setTextGap(int iconTextGap)


Correct Option: D
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.

Which of the following methods is not present in AbstractButton class in java?

  1. setRolloverEnabled(boolean)

  2. setPressedIcon(Icon)

  3. setDisabledIcon(Icon)

  4. setSelectedIcon(Icon)

  5. setSelectedRolloverIcon(Icon)


Correct Option: E
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.

- Hide questions