wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CC103 - FINAL SUMMATIVE

Total questions: 70

Worksheet time: 23mins

Name
Class
Date
1.

Which component creates a window in a Java Swing application?

a)

JLabel

b)

JButton

c)

JFrame

d)

JPanel

2.

Which Swing component is used to display static text?

a)

JTextField

b)

JLabel

c)

JCheckBox

d)

JRadioButton

3.

JTextField allows the user to:

a)

Click buttons

b)

Enter multi-line text

c)

Choose from a list

d)

Type a single line of text

4.

Which component responds to user clicks?

a)

JLabel

b)

JTextField

c)

JButton

d)

JComboBox

5.

Which component allows multiple options to be selected?

a)

JLabel

b)

JRadioButton

c)

JCheckBox

d)

JButton

6.

JComboBox is best used for:

a)

Entering text

b)

Clicking actions

c)

Selecting from a dropdown list

d)

Displaying images

7.

FlowLayout places components:

a)

In a grid

b)

In five regions

c)

From left to right

d)

Overlapping

8.

BorderLayout divides the container into:

a)

Three regions

b)

Two columns

c)

Five areas

d)

One panel

9.

What method sets the window's title?

a)

setLabel()

b)

setText()

c)

setTitle()

d)

setName()

10.

Which method makes a JFrame visible?

a)

setEnabled()

b)

setVisible(true)

c)

show()

d)

display()

11.

setResizable(false) will:

a)

Hide the window

b)

Make the window unresizable

c)

Make it fullscreen

d)

Set background color

12.

Which method adds a component to a JFrame?

a)

include()

b)

setComponent()

c)

add()

d)

join()

13.

JLabel(String text) creates:

a)

An image

b)

A button

c)

A label with text

d)

A combo box

14.

The method to add a tooltip is:

a)

setTipText()

b)

setHintText()

c)

setToolTipText()

d)

setHelp()

15.

JCheckBox(String, boolean) creates a checkbox with:

a)

Image only

b)

No label

c)

Label and state

d)

Text input

16.

getText() on a JCheckBox returns:

a)

Text label

b)

State

c)

Background color

d)

Font size

17.

What does isSelected() return?

a)

Text

b)

True/False

c)

Integer

d)

Font

18.

To insert an item into a JComboBox:

a)

addChoice()

b)

setItem()

c)

addItem()

d)

append()

19.

What component displays scrollbars?

a)

JTextField

b)

JScrollPane

c)

JLabel

d)

JButton

20.

JScrollPane(Component) does what?

a)

Sets color

b)

Displays the given component with scrollbars

c)

Adds a button

d)

Creates a menu

21.

JPanel is:

a)

A scrollable area

b)

A simple container

c)

A text field

d)

A label

22.

JPanel can be initialized with:

a)

Layout manager

b)

Only integers

c)

Images only

d)

setText()

23.

getContentPane() is used to:

a)

Access label

b)

Add components to JFrame

c)

Show the tooltip

d)

Exit window

24.

What does the Color class help with?

a)

Input

b)

Events

c)

Coloring components

d)

Adding titles

25.

setFont() is used to:

a)

Display image

b)

Set font style and size

c)

Create layout

d)

Resize window

26.

GridLayout places components:

a)

Overlapping

b)

In rows and columns

c)

On top of each other

d)

In a circle

27.

What component is not resizable by default?

a)

JFrame

b)

JLabel

c)

JButton

d)

JScrollPane

28.

JButton(Action a) is used when:

a)

Multiple buttons share the same behavior

b)

Text is needed

c)

ComboBox is needed

d)

JLabel is used

29.

What class controls component alignment in FlowLayout?

a)

AlignmentManager

b)

FlowStyle

c)

FlowLayout constants

d)

PanelManager

30.

JTextField(int columns) creates:

a)

A field with set column width

b)

A combo box

c)

A scroll area

d)

An image holder

31.

JComboBox is part of:

a)

AWT

b)

Swing

c)

Console

d)

JavaFX

32.

Which method sets JButton text?

a)

putText()

b)

setText()

c)

title()

d)

updateLabel()

33.

Which component can contain other components?

a)

JButton

b)

JLabel

c)

JPanel

d)

JTextField

34.

setBounds(x, y, width, height) sets:

a)

Font

b)

Alignment

c)

Window position and size

d)

Text input

35.

Font.PLAIN is a:

a)

Color

b)

Style

c)

Title

d)

Layout

36.

JFrame(String title) creates a JFrame with:

a)

No title

b)

Specified title

c)

A combo box

d)

Nothing

37.

JCheckBox has a square before:

a)

Combo box

b)

Label

c)

Icon

d)

Panel

38.

JButton(String, Icon) combines:

a)

Layout and font

b)

Text and image

c)

Window and frame

d)

Text and dropdown

39.

Icon is used for:

a)

Text alignment

b)

Fonts

c)

Images

d)

Titles

40.

The default layout for JPanel is:

a)

BorderLayout

b)

GridLayout

c)

FlowLayout

d)

None

41.

JLabel can use:

a)

Text only

b)

Icon only

c)

Text and icon

d)

Font only

42.

A JFrame without setVisible(true) is:

a)

Visible

b)

Hidden

c)

Resized

d)

Styled

43.

JTextField() creates:

a)

Label

b)

Empty text field

c)

ScrollPane

d)

Menu

44.

JScrollPane(int, int) allows:

a)

Font change

b)

Scrollbar settings

c)

Image view

d)

Title update

45.

getTitle() returns:

a)

JLabel

b)

JFrame title

c)

Font style

d)

Component size

46.

JPanel(LayoutManager, boolean) lets you:

a)

Set font

b)

Set layout and buffering

c)

Hide panel

d)

Add JTextField

47.

JCheckBox() creates:

a)

A scroll area

b)

Unlabeled checkbox

c)

Combo box

d)

Font field

48.

setSelected(true) marks JCheckBox as:

a)

Enabled

b)

Visible

c)

Selected

d)

Resized

49.

BorderLayout.CENTER adds a component to:

a)

Top

b)

Left

c)

Middle

d)

Bottom

50.

Which of these classes adds component scrolling?

a)

JPanel

b)

JScrollPane

c)

JTextField

d)

JFrame

51.

JLabel accepts user input.

a)

True

b)

False

52.

JTextField allows multi-line input.

a)

True

b)

False

53.

JComboBox allows typing text directly.

a)

True

b)

False

54.

GridLayout aligns components with varying sizes.

a)

True

b)

False

55.

JRadioButton allows selecting multiple options.

a)

True

b)

False

56.

The setTitle() method can be used on a JLabel.

a)

True

b)

False

57.

JScrollPane is used to hold buttons.

a)

True

b)

False

58.

JPanel cannot contain other components.

a)

True

b)

False

59.

JButton cannot contain both text and an image.

a)

True

b)

False

60.

JCheckBox cannot be selected programmatically.

a)

True

b)

False

61.

The setVisible() method is not required to display a JFrame.

a)

True

b)

False

62.

You cannot use layout managers with JPanel.

a)

True

b)

False

63.

JTextField(String, int) sets only the number of rows.

a)

True

b)

False

64.

Font.PLAIN is used for italic text.

a)

True

b)

False

65.

getContentPane() is used to add images only.

a)

True

b)

False

66.

JFrame is a top-level container in Swing.

a)

True

b)

False

67.

JButton can be clicked to trigger actions.

a)

True

b)

False

68.

FlowLayout is the default layout for JPanel.

a)

True

b)

False

69.

JCheckBox can be used to select multiple options.

a)

True

b)

False

70.

The getText() method retrieves the text from a JTextField.

a)

True

b)

False