Quiz #3 - Buttons

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Kawiz711
K
Kawiz711
Community Contributor
Quizzes Created: 3 | Total Attempts: 5,291
Questions: 10 | Attempts: 188

SettingsSettingsSettings
Quiz #3 - Buttons - Quiz

Questions and Answers
  • 1. 

    What three types of software are needed in a complete GUI program?

    • A.

      GUI Components, Event Methods, Application Methods

    • B.

      Action Events, Window Objects, Containers

    • C.

      Frames, Windows, Containers

    • D.

      Libraries, Toolkits, Interfaces

    Correct Answer
    A. GUI Components, Event Methods, Application Methods
    Explanation
    In a complete GUI program, GUI components are needed to create the visual elements of the user interface, such as buttons, labels, and text fields. Event methods are necessary to handle user interactions with these components, such as button clicks or text input. Application methods are required to perform the desired actions or operations based on these user interactions. These three types of software work together to create a functional and interactive graphical user interface.

    Rate this question:

  • 2. 

    How is a GUI component (such as a button) placed into a JFrame?

    • A.

      Insert( Component c )

    • B.

      Add( Component c )

    • C.

      Draw( Component c )

    • D.

      Put( Component c )

    Correct Answer
    B. Add( Component c )
    Explanation
    To place a GUI component, such as a button, into a JFrame, the correct method to use is "add(Component c)". This method is used to add the specified component to the container. In this case, the JFrame acts as the container and the button is the component being added. By using the "add" method, the button will be properly placed and displayed within the JFrame.

    Rate this question:

  • 3. 

    What is the Java software that determines how the components of a container are displayed?

    • A.

      Display Manager

    • B.

      Component Manager

    • C.

      Stage Manager

    • D.

      Layout Manager

    Correct Answer
    D. Layout Manager
    Explanation
    The Java software that determines how the components of a container are displayed is called the Layout Manager. It is responsible for arranging and positioning the components within a container, based on various layout rules and constraints. The Layout Manager helps in achieving a consistent and organized visual representation of the components, ensuring proper alignment and spacing.

    Rate this question:

  • 4. 

    Which manager displays components row-by-row, in the order in which they were added to the Frame?

    • A.

      CardLayout

    • B.

      FlowLayout

    • C.

      GridLayout

    • D.

      BorderLayout

    Correct Answer
    B. FlowLayout
    Explanation
    FlowLayout is the correct answer because it arranges components in a row-by-row manner, placing them in the order in which they were added to the frame. This layout manager is commonly used for creating simple and straightforward user interfaces where components are arranged horizontally until there is no more space, at which point they wrap to the next row.

    Rate this question:

  • 5. 

    What method of a JFrame is used to choose the layout manager?

    • A.

      SetLayout()

    • B.

      Add()

    • C.

      ActionPerformed()

    • D.

      SetVisible()

    Correct Answer
    A. SetLayout()
    Explanation
    The setLayout() method of a JFrame is used to choose the layout manager. This method allows the programmer to specify the layout manager that will be used to arrange the components within the JFrame. By calling setLayout() and passing in the desired layout manager as an argument, the programmer can control how the components are positioned and sized within the JFrame.

    Rate this question:

  • 6. 

    What interface must a class implement in order to be a listener for button ActionEvents?

    • A.

      TextListener

    • B.

      Runnable

    • C.

      ActionListener

    • D.

      ImageConsumer

    Correct Answer
    C. ActionListener
    Explanation
    A class must implement the ActionListener interface in order to be a listener for button ActionEvents. This interface provides the necessary methods to handle action events, such as actionPerformed(), which is invoked when a button is clicked. By implementing ActionListener, the class can receive and respond to button actions.

    Rate this question:

  • 7. 

    What method must be implemented in a listener for button events?

    • A.

      Paint()

    • B.

      WindowClosing()

    • C.

      AddActionListener()

    • D.

      ActionPerformed()

    Correct Answer
    D. ActionPerformed()
    Explanation
    The actionPerformed() method must be implemented in a listener for button events. This method is called when a button is clicked and it allows the listener to perform the desired action or behavior in response to the button event.

    Rate this question:

  • 8. 

    What method of a content pane changes its color?

    • A.

      SetBackground( Color c )

    • B.

      SetForeground( Color c )

    • C.

      Add()

    • D.

      GetBackground()

    Correct Answer
    A. SetBackground( Color c )
    Explanation
    The setBackground( Color c ) method of a content pane changes its color. This method takes a Color object as a parameter and sets the background color of the content pane to the specified color.

    Rate this question:

  • 9. 

    When should your program call repaint()?

    • A.

      Never--that is the system's job.

    • B.

      Only once when the frame is created.

    • C.

      Whenever a change has been made that should result in a new picture.

    • D.

      Always---whenever any method finishes.

    Correct Answer
    C. Whenever a change has been made that should result in a new picture.
    Explanation
    The program should call repaint() whenever a change has been made that should result in a new picture. This is because repaint() is responsible for requesting the system to repaint the component, which will update the visual representation of the program based on any changes made. Calling repaint() after a change ensures that the updated picture is displayed to the user.

    Rate this question:

  • 10. 

    What method will immediately stop a program?

    • A.

      System.gc()

    • B.

      System.exit( 0 )

    • C.

      System.setErr()

    • D.

      Return()

    Correct Answer
    B. System.exit( 0 )
    Explanation
    The method System.exit(0) will immediately stop a program. This method is used to terminate the currently running Java Virtual Machine (JVM). The argument 0 indicates a successful termination, while a non-zero argument indicates an abnormal termination. When System.exit(0) is called, the program will stop immediately and the control will be returned to the operating system.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 01, 2011
    Quiz Created by
    Kawiz711
Back to Top Back to top
Advertisement