What is the benefit of using layout managers

Assignment Help JAVA Programming
Reference no: EM131060292

Question 1

The method __________ sets the background color to yellow in JFrame frame.

setBackground(Color.YELLOW)

frame.setBackGround(Color.yellow)

setBackground(Color.yellow)

frame.setBackground(Color.YELLOW)

Question 2

What layout manager should you use so that every component occupies the same size in the container?

FlowLayout

any layout

BorderLayout

GridLayout

Question 3

Which of the following statements is for terminating the program when closing the frame?

frame.setDefaultCloseOperation(null)

frame.setDefaultCloseOperation(JFrame.TERMINATE_ON_CLOSE)

frame.setDefaultCloseOperation(JFrame.STOP_ON_CLOSE)

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

Question 4

Which of the following statements about containers is correct?

Both frames and panels can be placed inside a panel

A panel can be placed inside a panel

A frame can be placed inside a panel

A frame can be placed inside a frame

Question 5

Which method call puts the string "Result" into the TextField named result?

result.findText()

result.text("Result")

result.newText("Result")

result.setText("Result")

Question 6

How many items can be added into a JComboBox object?

0

1

Unlimited

2

Question 7

What kind of object is used group radio buttons?

Group

ButtonGroup

JButtonGroup

ContainerGroup

Question 8  

Which of the following method calls is used to prevent the user from modifying a text field tf?

tf.setUneditable()

tf.setEditable(false);

tf.preventMdification()

tf.setChangable(false);

Question 9

When you want to allow the user to select only one of several choices, which you use?

Text fields

Ordinary buttons

Radio buttons

Check boxes

Question 10

What is the benefit of using layout managers?

It reduces the amount of code needed

It defines how components of a window should be arranged when it is resized

It makes the program run much faster

It reduces the amount of memory necessary to store the window components

Question 11

Which of the following true about source and listener objects?

Both objects must be of the same type

The objects must always be of different types

They must always be different objects

They can be the same object

Question 12

Which of the following statements is incorrect?

A listener may listen for multiple sources

The listener object's class must implement the corresponding event-listener interface

A source object can only have one listener object

The listener object must be registered by the source object

Question 13

Given the code below, indicate which statement describes its behavior.

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Quiz3A extends JFrame implements ActionListener

{

   public Quiz3A()

   {

       JButton okButton = new JButton("OK");

       add(okButton);

   }

   public void actionPerformed(ActionEvent e)

   {

       System.out.println("The OK button is clicked");

   }

   public static void main(String[] args)

   {

       JFrame frame = new Quiz3A();

       frame.setSize(300, 300);

       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

       frame.setVisible(true);

   }

}

The actionPerformed method is not executed when you click the OK button, because no instance of Quiz3A is registered with okButton

The program has a compilation error because no listeners are registered for okButton

The message The OK button is clicked is displayed when you click the OK button

The program has a runtime error because no listeners are registered with okButton

Question 14

The listener for an button event is an instance of ________.

KeyListener

ActionListener

MouseListener

ItemListener

Question 15

Which of the following statements registers a panel object aPanel as a listener for a button variable aButton?

aButton.addActionEventListener(aPanel);

addActionListener(aPanel);

aPanel.addEventListener(aPanel);

aButton.addActionListener(aPanel);

Question 16

In the program below, which object is listening for the events of okButton?

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Quiz3B extends JFrame implements ActionListener

{

   private JButton okButton = new JButton("OK");

   public Quiz3B()

   {

       add(okButton);

       okButton.addActionListener(this);

   }

   public void actionPerformed(ActionEvent e)

   {

       System.out.println("The OK button is clicked");

   }

   public static void main(String[] args)

   {

       JFrame frame = new Quiz3B();

       frame.setSize(300, 300);

       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

       frame.setVisible(true);

   }

}

okButton

An anonymous object

frame

JButton

Question 17

What is the benefit of using adapter classes rather than listeners interfaces?

Question 17 options:

It enables multiple inheritance of classes

It makes it unnecessary to implement unused event handling methods

It makes the response time for responding to events much quicker

It makes it possible to respond to several events at the same time

Question 18

In the program below, which object is listening for the events of okButton?

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Quiz3C extends JFrame

{

   private JButton okButton = new JButton("OK");

   public Quiz3C()

   {

       add(okButton);

       okButton.addActionListener(

               new ActionListener()

               {

                   @Override

                   public void actionPerformed(ActionEvent ae)

                   {

                       System.out.println("The OK button is clicked");

                   }

               });

   }

   public static void main(String[] args)

   {

       JFrame frame = new Quiz3C();

       frame.setSize(300, 300);

       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

       frame.setVisible(true);

   }

}

An anonymous object

frame

JButton

okButton

Question 19

Which of the following will occur if you fail to register an object as a listener for the click events of a button?

The containing frame will be considered as the default listener

A compilation error will occur

Nothing will happen when the button is clicked

A class cast exception will be thrown at run-time

Question 20

When a mouse event is generated how is the location of the click point determined?

The event handler must generate a secondary event to obtain the location

It is automatically saved as an instance variable in the object of which the mouse was clicked

It is obtained by calling a method of the mouse object

It is extracted from the mouse event that is passed to the event handler.

Reference no: EM131060292

Questions Cloud

Characteristics influence buying behavior : The aim of marketing is to meet and satisfy target customer's needs and wants better than competitor's. Getting into the psyche of the consumer is a primary goal of marketers. 1. How does a buyer's characteristics influence buying behavior? Provid..
Carnival cruise lines : This company has had its image damaged severely by mishaps, bad publicity, angry customers, etc. The situation may be hopeless. On the other hand, this is an opportunity to think strategically. Imagine that you are an MBA working for the company. ..
Which is not among the functions of contract : Which of the following would not be classified as a capital expenditure for decision-making purposes?
Develop a tentative thesis : The major assignment for this week is to compose a 900-word essay on the Narrative of the Life of Frederick Douglass. In this paper you will write an in-depth analysis using your own ideas and excerpts from the text in the form of quotes, paraphra..
What is the benefit of using layout managers : What is the benefit of using layout managers? When a mouse event is generated how is the location of the click point determined? What layout manager should you use so that every component occupies the same size in the container?
Nature of the business market : 1. Which of the following statements regarding the nature of the business market is true? 2. Which of the following is the largest segment of the business market?
How social media analytics can generate value for case : Write an individual report analysing how social media analytics can generate value for your case organisation. Your report may - but is not required to - contain the following: IntroducAon to social media analytics in your organisation
Is there evidence of this in the data : Discuss the findings from parts (a) and (b). Is the Poisson distribution a good model for the customer error data? Is there evidence of this in the data?
Brand and model of the motherboard : 1. What is the brand and model of the motherboard? 2. What chipset does this board use? 3. What troubleshooting utilities are found on the CD that came bundled with the board?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Sentence patterns and verb formulas

Provide the sentence pattern. Write out the sentence pattern - then write out the tense of the verb and provide the formula.

  Write a java program that calculates and displays the result

Write a Java program that calculates and displays the results of addition, subtraction, multiplication, division, modulus, bitwise &, or bitwise | operation on two integer values input by the user.

  Implement elliptic curve encryption - decryption in java

Implement Elliptic Curve encryption - decryption in java. Specifically, your program will read parameters, plaintext and ciphertextfrom a file

  Write a program to play a game of craps

Write a program to play a game of "craps," a dice game popular in casinos. Here are the rules - Use functions appropriately. The program should allow the user to play another round.

  Consider a class that could be used to play a game of

consider a class that could be used to play a game of hangman. the class has the following attributesthe secret wordthe

  Evaluates an arithmetic expression in postfix expression

Bring a hardcopy of your source code to class in order to submit. Please staple multiple pages together. Write a program that evaluates an arithmetic expression in postfix expression. In your program you will need a stack implemented as a linked list..

  Write a java script code for a function called areabox

Write a Html/Java Script code that does the following 1) A Function called AreaBox that takes two parameters,length & width of the rectangle and returns the Area of the Rectangle.

  Create your own unique java application

Create your own unique Java application to read all data from the file echoing the data to standard output. After all data has been read, display how many data were read. For example, if 10 integers were read, the application should display all 10..

  Question regarding the wireless systems

Discuss the evolution of transmission media up to now, and prediction of such evolution into the future, as the demand for bandwidth keeps rising. Also explore signal handling techniques, such as modulation, OFDM, and MIMO, particularly used in w..

  Write a program for sending and receiving a file

Write a program for sending and receiving a file that uses Hamming code for error correction - The encoder should generate file encoded that consists of codewords and should be twice the size of the original dataFile.

  Need usual internal node structure and constructor

Create a basic, generic DataTree class. As described, it will consist of a binary tree structure, and will need the usual internal node structure and constructor -  Write the other methods used in Section One of the commented-out test code in Main..

  Write a server for multiple clients

Write a server for multiple clients. The client sends loan information (annual interest rate, number of years, and loan amount) to the server. The server computes monthly payment and total payment and sends them back to the client.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd