0

Java Basics (GATE)

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

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

  1. getMargin()

  2. getText()

  3. getIconTextGap()

  4. getLabel()

  5. getMnemonic()


Correct Option: D
Explanation:

This is the correct choice. getLabel() method was earlier defined in the AbstractButton class, but now this method has been deprecated and is replaced by getText() method. This method is used to get the button's text.

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

  1. getRowCount()

  2. getRowHeight()

  3. invalidateSizes()

  4. isRootVisible()

  5. isRowHeightFixed()


Correct Option: E
Explanation:

This is the correct choice. There is no method named isRowHeightFixed() in AbstractLayoutCache class. The correct method name is isFixedRowHeight(). This method returns true if the height of each row is of a fixed size.

Which of the following methods is not present in the TableModel Interface in java?

  1. getValueAt(int rowIndex, int colIndex)

  2. getColCount()

  3. setValueAt(Object aValue, int rowIndex, int colIndex)

  4. getRowCount()

  5. isCellEditable(int rowIndex, int colIndex)


Correct Option: B
Explanation:

This is the correct choice. There is no method named getColCount() in TableModel Interface. The correct method name is getColumnCount() and it returns the number of columns in a model. 

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

  1. getLength()

  2. getStartPosition()

  3. getDocumentContent()

  4. writeUnlock()

  5. getEndPosition()


Correct Option: C
Explanation:

This is the correct answer. There is no method named getDocumentContent() in the AbstractDocument class. The correct method name is getContent(). This method is used to retrieve the content for a document.

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

  1. isLeftToRight()

  2. isRightToLeft()

  3. getCharacterCount()

  4. isVertical()

  5. getBounds()


Correct Option: B
Explanation:

This is the correct choice. There is no method named isRightToLeft() present in the TextLayout class. The correct method name is isLeftToRight() and it returns true if this TextLayout has a left-to-right base direction or false if it has a right-to-left base direction.

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

  1. layoutSize(Container parent)

  2. minLayoutSize(Container parent)

  3. setCols(int cols)

  4. getCols()

  5. All of the above


Correct Option: E
Explanation:

This is the correct choice. As explained, all the given methods are not defined in the GridLayout class. 

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

  1. sizeWidthToFit()

  2. getMaximumWidth()

  3. getIdentifier()

  4. getPreferredWidth()

  5. getResizable()


Correct Option: B
Explanation:

This is the correct answer. There is no method named getMaximumWidth() in TableColumn class. The correct method name is getMaxWidth() and it returns the maximum width for the TableColumn.

Which of the following methods is not present in the ImageInputStream Interface in java?

  1. isCached()

  2. getImage()

  3. readBoolean()

  4. getStreamPosition()

  5. flush()


Correct Option: B
Explanation:

This is the correct choice. getImage() method is not present in the ImageInputStream Interface. This method is present in the ImageIcon class and it returns the image associated with this particular icon.

Which of the following methods in HttpCookie class returns the maximum age of the cookie in seconds?

  1. getMaxAgeInSeconds()

  2. getMaxAge()

  3. getMaximumAge()

  4. getMaximumAgeInSeconds()

  5. getAge()


Correct Option: B
Explanation:

This is the correct choice. getMaxAge() method is present in the HttpCookie class. This method returns the maximum age of the cookie, specified in seconds.

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

  1. getPath()

  2. getValue()

  3. isHttpOnly()

  4. getMaximumAge()

  5. clone()


Correct Option: D
Explanation:

This is the correct choice. There is no method named getMaximumAge() in HttpCookie class. The correct method name is getMaxAge(). This method returns the maximum age of the cookie, specified in seconds.

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

  1. getImageURL()

  2. getNoImageIcon()

  3. getAltText()

  4. getLoadingImageIcon()

  5. getURL()


Correct Option: E
Explanation:

This is the correct choice. There is no method named getURL() in ImageView class. The correct method name is getImageURL(). This method returns a URL for an image source or null if it could not be determined.

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

  1. getCols()

  2. getMinimumSize()

  3. getRows()

  4. append(String str)

  5. insert(String str, int pos)


Correct Option: A
Explanation:

This is the correct choice. There is no method named getCols() present in the TextArea class. The correct method name is getColumns(), which is used to retrieve the number of columns in this text area.

Which of the following methods is present in the GroupLayout class in java?

  1. setVGap(int gap)

  2. setVGroup(GroupLayout.Group group)

  3. getLayoutAlignmentY(Container parent)

  4. minLayoutSize(Container parent)

  5. layoutSize(Container parent)


Correct Option: C
Explanation:

This is the correct choice. getLayoutAlignmentY(Container parent) method is present in the GroupLayout class. This method returns the alignment along the y-axis.

Which of the following methods in TextField class fetches the minimum dimensions for this text field?

  1. minimumSize()

  2. minSize()

  3. getMinSize()

  4. getMinimumSize()

  5. getMinDimensions()


Correct Option: D
Explanation:

This is the correct choice. getMinimumSize() method is present in the TextField class and it returns the minimum dimensions for this text field.

Which of the following methods in AbstractButton class returns the margin between the button border and the label?

  1. getTextBorderGap()

  2. getBorderLabelMargin()

  3. getMargin()

  4. getTextBorderMargin()

  5. getIconTextGap()


Correct Option: C
Explanation:

This is the correct choice. getMargin() method is present in the AbstractButton class and it is used to get the margin between the button border and the label.

- Hide questions