wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java AWT Swings Quiz 1

Total questions: 24

Worksheet time: 11mins

Name
Class
Date
1.

Java was originally named:

a)

Coffee

b)

Oak

c)

New C++

d)

Duke

2.

From where did Java get its name?

a)

Coffee

b)

Book

c)

TV Programme

d)

Initials of the developers of Java

3.

When was Java released?

a)

1975

b)

1985

c)

1995

d)

2005

e)

2015

4.

What is the name of the Java mascot?

a)

Duke

b)

Ronny

c)

Penguin

d)

James

e)

Jack

5.

What was Java originally designed for?

a)

Interactive TV

b)

Internet

c)

Gaming

d)

Cars

6.

Which company owns Java?

a)

Oracle

b)

Microsoft

c)

Google

d)

Apple

e)

Intel

7.

What is the purpose of the line of code:

import java.awt.*;

a)

To allow you to make Random number generators

b)

To use an interface.

c)

To import a package

d)

To allow you to Scan from the terminal or a file.

8.

Which of the lines of code DOES NOT call a method?

a)

frame.setSize()

b)

frame.setVisible(true);

c)

JFrame frame;

d)

frame.setResizable(false);

9.

JFrame, JPanel, JLabel, JButton are examples of ...

a)

methods

b)

classes

c)

interfaces

d)

packages

10.

What code adds this JButton to this JPanel?

JPanel panel = new JPanel();

JButton button = new JButton();

a)

panel.add(button);

b)

button.add(panel);

c)

frame.add(panel);

d)

panel.add(JButton);

11.

How would you change the text of a label to the text contained by an integer named num;

a)

label.setText(num);

b)

label.updateText(num);

c)

label.setTest("num");

d)

label.setText(num+ "");

12.

Which of the following layouts would be good to use for GUI that resembles a computer keyboard?

a)

Flow Layout

b)

Border Layout

c)

Grid Layout

d)

Null Layout

13.

Which of the following layouts would be good to use for GUI that adjusts the position of objects when the screen is resized?

a)

Flow Layout

b)

Border Layout

c)

Grid Layout

d)

Null Layout

14.

Which of the following layouts would be good to use for manually placing objects on a GUI?

a)

Flow Layout

b)

Border Layout

c)

Grid Layout

d)

Null Layout

15.

What method(s) must we include in order to implement ActionListener?

a)

paintComponent

b)

actionEvent

c)

actionPerformed

d)

keyPressed

16.

What method(s) must we include in order to implement KeyListener?

a)

keyTyped

b)

keyPressed

c)

keyReleased

d)

keyUsed

17.

On a 1000 x 800 pixel JFrame, when we run the line of code below what shape appears on the screen?


g.fillRect(500,400, 30, 30);

a)

A filled in square that is 30 pixels by 30 pixels.

b)

A filled in rectangle that is 500 pixels wide by 400 pixels in height.

c)

A filled in rectangle that is 400 pixels wide by 500 pixels in height.

d)

The border of a rectangle that is 500 pixels wide by 400 pixels in height.

18.

When you run the code below, what color will the rectangle be?


g.setColor(Color.BLUE);

g.fillRect(LpaddleX, LpaddleY, paddleW, paddleH);

g.setColor(Color.RED);

a)

RED

b)

BLUE

c)

You'll get an error. Those colors aren't valid.

19.

In order to make a class that inherits characteristics of JPanel, we need to use the key word...

a)

public

b)

class

c)

extends

d)

implements

e)

throws

20.

Which items below are interfaces?

a)

ActionListener

b)

JPanel

c)

KeyListener

d)

IOException

21.

Which of the following is true about AWT and Swing components.

a)

AWT components creates a process where as swing components creates a thread

b)

AWT components creates a thread where as swing components creates a process

c)

Both AWT and Swing components creates a process

d)

Both AWT and swing components creates a thread

22.

Which class is used to represent a single line textbox with password character facility?

a)

TextField

b)

TextArea

c)

Label

d)

Checkbox

23.

The method ___________ places a Menu m into the MenuBar mb.

a)

mb.addMenuItem(m)

b)

mb.addItem(m)

c)

mb.add(m)

d)

None of these

24.

Which of these Components cannot be added to Frame?

a)

Label

b)

ScrollPane

c)

CheckBoxGroup

d)

None of the above