Create Software Components 

Using Java Level 2

 

 

Course Info

Scheme

Resources

Tutorials

Java Demos

Utilities

Links


 

    Quiz 9

Swing Components

There are 25 questions

Question 1.         

A component is

 

(a)   an application object

(b)   a class method

(c)   a visual object with which a user can interact

(d)   a part of an instance of a class

Question 2.         

The main superclass of swing components is...

 

(a)  JPanel

(b)  JComponent

(c)  Frame

(d)  Container 

Question 3.         

What is the main class called from which all other classes ultimately descend?

 

______________________

Question 4.         

Which one of the following are components only?

 

(a)   Button, Font, Label

(b)   Button, Label, LayoutManager

(c)   Label, Button, TextArea

(d)   Label, Panel, Menu.

Question 5.         

Which one of the following expressions correctly sets the text color of a label to blue?

 

(a)  lbl.setForeground(Colour.blue);

(b)  lbl.setForeground(0,0,255);

(c)   lbl.setBackground(Colour.blue);

(d)   lbl.setBackground(0,0,255);  

Question 6.         

What do you call a text component that cannot be modified by the user?

 

______________________

Question 7.         

Write down the method and parameter value you would use to make a text field or text area uneditable.

 

______________________

Question 8.         

Supposing you have created a container and a component.  Which method would you use to show the component in the container?

 

______________________

Question 9.         

Suppose you want to take out a component from a container, which method would  you use?

 

______________________

Question 10.         

A panel cannot be added to another panel...

 

(a)   true

(b)   false

Question 11.         

Write down an expression to add a swing radio button referenced by a variable bt to an applet.

 

_________________________________________________

Question 12.         

Write down an expression to add a swing combo box referenced by the variable aCombo to a swing panel referenced by the variable mainPanel.

 

_________________________________________________

Question 13.         

The following statement is incorrect.

JButton cmd = JButton("Hi everyone!");

Write down the correct way of creating an instance of a JButton.

 

_________________________________________________

Question 14.         

The following statement is incorrect.

JCheckBox = new JCheckBox ("Select Me");

Write down a correct statement.

 

_________________________________________________

Question 15.         

Which of the following expression creates an action button with a caption and an image?

 

(a)  JButton but1 = new  JButton ();

(b)  JButton but1 = new  JButton (new ImageIcon ("sun.gif"));

(c)  JButton but1 = new  JButton ("hi", new ImageIcon ("sun.gif"));

(d)  JButton but1 = new  JButton ("hi");

Question 16.         

Checkboxes provide a set of mutually exclusive options.

 

(a)   true

(b)   false

Question 17.         

Radio buttons provide a set of mutually exclusive options.

 

(a)   true

(b)   false 

Question 18.         

Write down the name of the class used to create groups of radio buttons.

 

______________________

Question 19.         

Write down an expression to set the font of a text field referenced by the variable aText to Arial, bold and size 14 points.

_________________________________________________

Question 20.         

What is the difference between a TextArea and a TextField?

 

(a)   A TextArea can handle multiple lines of text but a TextField cannot

(b)   A TextArea can be used for text output but aTextField cannot

(c)   A TextArea is a class but a TextFields is an instance of a class.

(d)   You can only draw onto TextAreas.

Question 21.         

Two of the following components displays a scrollbar if there is not enough room to display everything. Which two?

 

(a)   JList 

(b)   JScrollPane

(c)   JTextArea

(b)   JComboBox

 

Question 22.         

Let's suppose you wish to change the text displayed by a label which has already been created.  Which method would you use?

 

______________________

Question 23.         

Let's suppose you wish to disable an action button.  Which method and parameter value would you use?

 

______________________

Question 24.         

Let's suppose you wish to make a label invisible.  Which method and parameter value would you use?

 

______________________

Question 25.         

Let's suppose you wish to set the background color of a label referenced by the variable anotherLabel to yellow.  Write down the expression would you use?

 

______________________

 

        

 

  Site Home 

Java Home   

  Forum  

Course Info

Welcome

Overview

Assessment

Qualification

Scheme of Work

Assignments

Resources

Information

Blackboard

Learning Center

Web Materials

Reading

Java Demos

Utilities

Links

Lecture Materials

Tutorials & Notes

Exercises

Activities

Quizzes

 

Site Home

Top

Unit Home

ADR 2002