Java: Chapter 12 Quiz

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

When using the BorderLayout manager, how many components can each region hold? A) 1 B) No limit C) 5 D) 2

A) 1

This layout manager arranges components in five regions. A) BorderLayout B) RegionLayout C) FlowLayout D) GridLayout

A) BorderLayout

This is a basic window that has a border around it, a title bar, and a set of buttons for minimizing, maximizing, and closing the window. A) Frame B) Container C) Dialog box D) Pane

A) Frame

When this is the argument passed to the JFrame class's setDefaultCloseOperation() method, the application is hidden, but not closed. A) JFrame. HIDE_ON_CLOSE B) JFrame.HIDE_NOT_CLOS C) HIDE_ON_CLOSE D) JFrame.EXIT_ON_CLOSE

A) JFrame. HIDE_ON_CLOSE

Which of the following statements is NOT true? A) Radio buttons and check boxes both implement the ActionListener interface. B) Radio buttons are often grouped together and are mutually exclusive; Check boxes are not. C) Radio buttons are round and check boxes are square. D) They are all true.

A) Radio buttons and check boxes both implement the ActionListener interface.

These components have a consistent look and predictable behavior on any operating system. A) Swing B) Peer classes C) GUI D) AWT

A) Swing

When an application uses many components, rather than deriving just one class from the JFrame class, it is often better to encapsulate smaller groups of related components and their event listeners into their own class. A commonly used technique to do this is: A) To extend a class from the JPanel class to contain other components and their related code B) To extend a class from the JAbstractButton class to contain other components and their related code C) To extend a class from the JComponent class to contain other components and their related code D) To extend a class from the JFrame class to contain other components and their related code

A) To extend a class from the JPanel class to contain other components and their related code

This is an action that takes place in an application, such as the clicking of a button. A) event B) effect C) instance D) case

A) event

To use the ActionListener interface, as well as other event listener interfaces, you must have the following import statement in your code: A) import java.awt.event.*; B) import java.awt.*; C) import java.awt; D) import java.swing;

A) import java.awt.event.*;

One of the small dots that make up a screen display is known as what? A) pixel B) texture C) color D) point

A) pixel

Which of the following statements creates a class that is extended from the JFrame class? A) public class DerivedClass extends JFrame{} B) JFrame DerivedClass = new JFrame(); C) JFrame(DerivedClass); D) class JFrame DerivedClass;

A) public class DerivedClass extends JFrame{}

When a component is added to a region in the BorderLayout manager: A) the component is stretched so it fills up the entire region B) the component retains its original size C) it results in a compile time error, if it is too large D) the region is resized to fit the component

A) the component is stretched so it fills up the entire region

When adding components to a container that is governed by the GridLayout manager: A) you cannot specify a cell B) you specify the cell with the row and column numbers in the add statement C) you must add them starting with the lower, right cell D) the components are added automatically by filling up the first column, then the second, etc.

A) you cannot specify a cell

Because these components rely on the appearance and behavior of the underlying operating system components, there is little that can be done by the programmer to change their properties. A) JFC B) AWT C) Swing D) Container

B) AWT

What does the following statement do? addButton.addActionListener(new AddButtonListener()); A) Registers the addButton object as an ActionListener with the AddButtonListener object B) Creates an AddButtonListener object and registers the AddButtonListener object with the addButton C) Creates an AddButtonListener object D) Nothing, the statement is invalid.

B) Creates an AddButtonListener object and registers the AddButtonListener object with the addButton

In Swing, labels are created with this class: A) SwingLabel B) JLabel C) JFCLabel D) AWTLabel

B) JLabel

This is a graphic image that is displayed while an application loads into memory and starts up. A) Memory usage screen B) Splash screen C) Blue screen of death D) The Java 8 trademark screen

B) Splash screen

If button1 is a JButton object, which of the following statements will make its background blue? A) button1.set.Background(BLUE); B) button1.setBackground(Color.BLUE); C) button1.makeBackground(BLUE); D) button1.makeBackground(Color.BLUE);

B) button1.setBackground(Color.BLUE);

Programs that operate in a GUI environment must be: A) in color B) event driven C) dialog boxes D) layout managers

B) event driven

You use the ________ key word in a class header to indicate that it implements an interface. A) static B) implements C) listener D) interface

B) implements

If panel references a JPanel object, which of the following statements adds the GridLayout to it? A) panel.addLayout(new (GridLayout(2,3)) B) panel.setLayout(new (GridLayout(2,3)); C) panel.GridLayout(2,3); D) panel.attachLayout(GridLayout(2,3));

B) panel.setLayout(new (GridLayout(2,3));

This layout manager arranges components in regions named North, South, East, West, and Center. A) RegionLayout B) FlowLayout C) BorderLayout D) GridLayout

C) BorderLayout

To end an application, pass this as the argument to the JFrame class's setDefaultCloseOperation() method. A) JFrame.CLOSE_NOT_HIDE B) JFrame.END_ON_CLOSE C) JFrame.EXIT_ON_CLOSE D) END_ON_CLOSE

C) JFrame.EXIT_ON_CLOSE

JFC stands for: A) Java Fundamental Classes B) Java Frame Class C) Java Foundation Classes D) Java Fundamental Core

C) Java Foundation Classes

________ is a library of classes that do not replace ________, but provide an improved alternative for creating GUI applications. A) JFC, Swing B) AWT, Swing C) Swing, AWT D) JFC, AWT

C) Swing, AWT

What will be the result of executing the following statement? panel.setBorder(BorderFactory.createLineBorder(Color.BLUE, 5)); A) The JPanel referenced by panel will have a blue line border that is 5 inches thick. B) The JPanel referenced by panel will have a blue line border that is 5 characters thick. C) The JPanel referenced by panel will have a blue line border that is 5 pixels thick. D) The JPanel referenced by panel will have a blue line border that is 5 millimeters thick.

C) The JPanel referenced by panel will have a blue line border that is 5 pixels thick.

The variable panel references a JPanel object. The variable bGroup references a ButtonGroup object, which contains several button components. If you want to add the buttons to the panel: A) use the statement, bGroup.add(panel); B) use the statement, panel.add(bGroup); C) add each button to panel one at a time, e.g. panel.add(button1); D) use the statement, Panel panel = new Panel(bGroup);

C) add each button to panel one at a time, e.g. panel.add(button1);

When you write an action listener class for a JButton component, it must: A) have a method named actionPerformed which must take an argument of the ActionEvent type B) implement the ActionLIstener interface C) both implement the ActionLIstener interface and have a method named actionPerformed which must take an argument of the ActionEvent type D) have a method named buttonClicked

C) both implement the ActionLIstener interface and have a method named actionPerformed which must take an argument of the ActionEvent type

When an application uses many components, instead of extending just one class from the JFrame class, a better approach is to: A) just go ahead and do it in one large class B) reconsider the design of the application C) encapsulate smaller groups of related components and their event listeners into their own classes D) break the application into several smaller applications

C) encapsulate smaller groups of related components and their event listeners into their own classes

Assume that radio references a JRadioButton object. To click the radio button in code, use the following statement: A) Click(radio); B) radio.Click(); C) radio.doClick(); D) Click(radio, true);

C) radio.doClick();

How many radio buttons can be selected at the same time as the result of the following code? hours = new JRadioButton("Hours"); minutes = new JRadioButton("Minutes"); seconds = new JRadioButton("Seconds"); days = new JRadioButton("Days"); months = new JRadioButton("Months"); years = new JRadioButton("Years"); timeOfDayButtonGroup = new ButtonGroup(); dateButtonGroup = new ButtonGroup(); timeOfDayButtonGroup.add(hours); timeOfDayButtonGroup.add(minutes); timeOfDayButtonGroup.add(seconds); dateButtonGroup.add(days); dateButtonGroup.add(months); dateButtonGroup.add(years); A) 4 B) 3 C) 1 D) 2

D) 2

Assume that the variable checkbox references a JCheckBox object. To determine whether the check box has been selected, use the following code: A) <font face="Courier New">if (checkBox.doClick()) {&#47;*</font><i>code to execute, if selected<font face="Courier New">*&#47;</font></i><font face="Courier New">}</font> B) <font face="Courier New">if (isSelected(checkBox)) {&#47;*</font><i>code to execute, if selected<font face="Courier New">*&#47;</font></i><font face="Courier New">}</font> C) <font face="Courier New">if (checkBox) {&#47;*</font><i>code to execute, if selected<font face="Courier New">*&#47;</font></i><font face="Courier New">}</font> D) <font face="Courier New">if (checkBox.isSelected()) {&#47;*</font><i>code to execute, if selected<font face="Courier New">*&#47;</font></i><font face="Courier New">}</font>

D) <font face="Courier New">if (checkBox.isSelected()) {&#47;*</font><i>code to execute, if selected<font face="Courier New">*&#47;</font></i><font face="Courier New">}</font>

Which of the following is NOT a rule for the FlowLayout manager? A) Multiple components can be added to a container that uses a FlowLayout manager. B) New components will be added in a row from left to right. C) When there is no more room in a row, additional components are put on the next row. D) All of these are rules for the FlowLayout manager.

D) All of these are rules for the FlowLayout manager.

Which of the following statements is NOT true? A) Radio buttons implement ActionListener; Check boxes implement ItemListener. B) Radio buttons are often grouped together and are mutually exclusive; Check boxes are not. C) Radio buttons are round and check boxes are square. D) All of these are true.

D) All of these are true.

This layout manager arranges components in rows. A) BorderLayout B) RegionLayout C) GridLayout D) FlowLayout

D) FlowLayout

Which one of the following GUI components is considered to be a container? A) Label B) Button C) Slider D) Frame

D) Frame

In a Swing application, you create a frame object from the: A) Jpanel B) AbstractButton C) Jlabel D) JFrame

D) JFrame

The GridLayout manager limits each cell to only one component. To put two or more components in a cell, do this: A) Resize the cells so they can hold more B) Resize the components to fit in the cell C) The statement is false. The GridLayout manager does not have this restriction D) You can nest panels inside the cells, and add other components to the panels

D) You can nest panels inside the cells, and add other components to the panels

The minimize button, maximize button, and close button on a window are sometimes referred to as: A) sizing buttons B) display buttons C) operations buttons D) decorations

D) decorations

Event listeners must: A) be included in private inner classes B) exit the application once it has handled the event C) not receive any arguments D) implement an interface

D) implement an interface

To include Swing and AWT components in your program, use the following import statements: A) import java.swing; import javax.awt; B) import java.swing; import java.awt; C) import javax.swing; import javax.awt; D) import javax.swing; import java.awt;

D) import javax.swing; import java.awt;

You would use this command at the operating system command line to execute the code in the MyApplication class and display the graphic image Logo.jpg as a splash screen. A) java Logo.jpg -splash&#58;MyApplication B) java MyApplication Logo.jpg C) java MyApplication -splash D) java -splash&#58;Logo.jpg MyApplication

D) java -splash&#58;Logo.jpg MyApplication

This is commonly used to hold and organize collections of related components: A) list B) label C) frame D) panel

D) panel

A GUI program automatically stops executing when the end of the main method is reached. True/False

False

All operating systems offer the same set of GUI components. True/False

False

The FlowLayout manager does not allow the programmer to align components. True/False

False

The following statement adds the FlowLayout manager to the container, centers the components, and separates the components with a gap of 10 pixels. setLayout(new FlowLayout()); True/False

False

When a splash screen is displayed, the application does not load and execute until the user clicks the splash screen image with the mouse. True/False

False

You must use the statement import java.swing.*; in order to use the ItemListener interface. True/False

False

A common technique for writing an event listener class is to write it as a private inner class inside the class that creates the GUI. True/False

True

Check boxes may be grouped in a ButtonGroup, like radio buttons are. True/False

True

Some of the common GUI components are buttons, labels, text fields, check boxes, and radio buttons. True/False

True

The ActionEvent argument that is passed to an action listener's actionPerformed method is the event object that was generated in response to an event. True/False

True

The System.exit method will end the application.executing. True/False

True

The ability to display splash screens was introduced in Java 6. True/False

True


Set pelajaran terkait

chapter 14, 15, 16 pharm meas 218 exam 4

View Set

Underwriting and Policy Issue - Chapter Exam Answers

View Set

Section VI - Community Reinvestment Act, CRA Sunshine, and Prohibition against use of Interstate Branches Primarily for Deposit Production

View Set

Lecture 3: Tsunamis, Coastal Hazards

View Set

Ch 24 Fluids and electrolytes Assignment

View Set

Solving Equations and Inequalities

View Set