Java: Swing Frames Trivia Quiz

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,592
Questions: 10 | Attempts: 2,831

SettingsSettingsSettings
Java: Swing Frames Trivia Quiz - Quiz

What do you know about Java? This is a quiz on Java Swing frames. Are you ready for this Java: Swing Frames Trivia Quiz. J Frames work as the main window where components like labels, buttons, and text fields get added to create a GUI. Unlike Frame, J Frame contains the option to hide or close the window through the set Default Close Operation(int) method. Let's see how well you know through this quiz. Best of luck to you!


Questions and Answers
  • 1. 

    Swing class which is used for frames, is

    • A.

      Window

    • B.

      Frame

    • C.

      JFrame

    • D.

      SwingFrame

    Correct Answer
    C. JFrame
    Explanation
    The correct answer is JFrame. The Swing class is used for creating graphical user interface (GUI) components in Java. JFrame is a class that extends the Window class and provides functionalities for creating and managing frames, which are the main containers for GUI components in a Java application. Therefore, the correct answer is JFrame.

    Rate this question:

  • 2. 

    What sets the frame to 300 pixels wide by 200 high?

    • A.

      Frm.setVisible( 300, 200 );

    • B.

      Frm.paint( 300, 200 );

    • C.

      Frm.setSize( 200, 300 );

    • D.

      Frm.setSize( 300, 200 );

    Correct Answer
    D. Frm.setSize( 300, 200 );
    Explanation
    The correct answer is frm.setSize(300, 200). This method sets the size of the frame to be 300 pixels wide and 200 pixels high.

    Rate this question:

  • 3. 

    In what is the size of a frame on the screen measured?

    • A.

      Inches

    • B.

      Nits

    • C.

      Dots

    • D.

      Pixels

    Correct Answer
    D. Pixels
    Explanation
    The size of a frame on the screen is measured in pixels. Pixels are the smallest unit of measurement on a screen and refer to the individual dots that make up an image. The more pixels there are in a frame, the higher the resolution and clarity of the image.

    Rate this question:

  • 4. 

    container object in GUI programming is

    • A.

      Another name for an array or vector.

    • B.

      Any class that is made up of other classes.

    • C.

      A primitive variable that contains the actual data.

    • D.

      An object like a frame that has other GUI components placed inside of it.

    Correct Answer
    D. An object like a frame that has other GUI components placed inside of it.
    Explanation
    The correct answer is "An object like a frame that has other GUI components placed inside of it." In GUI programming, a container object refers to an object that can hold and organize other GUI components such as buttons, labels, or text fields. It acts as a parent or holder for these components, allowing them to be arranged and displayed within the container's boundaries. Common examples of container objects in GUI programming include frames, panels, and windows. These containers provide a structure and layout for the GUI components, enabling the creation of complex and interactive user interfaces.

    Rate this question:

  • 5. 

    Fill in the blanks to make this program display a JFrame:   import java.awt.*;     public class microGUI   {     public static void main ( String args[] )     {       JFrame frm = new ___________();       frm.___________( 150, 100 );       frm.___________( true );     }   }  

    • A.

      Form, setVisible, setOn

    • B.

      JFrame, setSize, setVisible

    • C.

      Frame, setVisible, setSize

    • D.

      Window, setSize, paint

    Correct Answer
    B. JFrame, setSize, setVisible
    Explanation
    The correct answer is JFrame, setSize, setVisible. In order to display a JFrame, we need to create a new JFrame object using the JFrame class. The setSize method is used to set the size of the JFrame, and the setVisible method is used to make the JFrame visible on the screen. Therefore, the correct code to display a JFrame would be "JFrame frm = new JFrame(); frm.setSize(150, 100); frm.setVisible(true);"

    Rate this question:

  • 6. 

    JFrame myFrame = new JFrame (); Any command (such as the listed one) which creates a new object of a specific class is usually called a...

    • A.

      Constructor

    • B.

      Layout manager

    • C.

      Parameter

    • D.

      GUI

    Correct Answer
    A. Constructor
    Explanation
    The given command "JFrame myFrame = new JFrame();" is creating a new object of the JFrame class. This is done by calling the constructor of the JFrame class, which is a special method used to initialize objects. Therefore, the correct answer is "constructor".

    Rate this question:

  • 7. 

    When you create a JFrame object, it is not automatically displayed.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    When a JFrame object is created, it is not automatically displayed because the display of the JFrame is controlled by the programmer. The programmer can choose when and how to display the JFrame by using methods such as setVisible(true) to make it visible on the screen. Therefore, the statement "When you create a JFrame object, it is not automatically displayed" is true.

    Rate this question:

  • 8. 

    How do you import all the classes in the AWT and Swing packages?

    • A.

      Import awt.* import swing.*

    • B.

      Import java.awt import javax.swing

    • C.

      Import java.awtx.* import java.swingx.*

    • D.

      Import java.awt.* import javax.swing.*

    Correct Answer
    D. Import java.awt.* import javax.swing.*
    Explanation
    This answer is correct because it imports all the classes in the AWT and Swing packages by using the wildcard (*) after the package names. This means that all the classes within these packages will be accessible in the current code file.

    Rate this question:

  • 9. 

    In Java, what do you name an area on the screen that has fine borders and various buttons on the top border?

    • A.

      A window.

    • B.

      A screen.

    • C.

      A box.

    • D.

      A frame.

    Correct Answer
    D. A frame.
    Explanation
    In Java, an area on the screen that has fine borders and various buttons on the top border is called a frame. A frame is a container that holds other components such as buttons, text fields, or labels. It provides a window-like structure with a title bar, minimize, maximize, and close buttons. Frames are commonly used to create graphical user interfaces (GUIs) in Java applications.

    Rate this question:

  • 10. 

    Upon clicking the X (close) button on a window, it looks like you have "killed" the program when in reality, it keeps on running, but you see no frame. This happened because you forgot to use the setDefaultCloseOperation( ) method, so by default, it used...

    • A.

      JFrame.EXIT_ON_CLOSE

    • B.

      JFrame.HIDE_ON_CLOSE

    • C.

      JFrame.DISPOSE_ON_CLOSE

    • D.

      JFrame.DO_NOTHING_ON_CLOSE

    Correct Answer
    B. JFrame.HIDE_ON_CLOSE
    Explanation
    When the X (close) button on a window is clicked without using the setDefaultCloseOperation( ) method, the default close operation is used. In this case, the default close operation is JFrame.HIDE_ON_CLOSE. This means that when the X button is clicked, the window is hidden, but the program continues to run in the background. So, although it may appear that the program has been "killed" because the window is no longer visible, it is actually still running.

    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
  • Jul 16, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 30, 2011
    Quiz Created by
    Kawiz711
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.