wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

POST QUIZ JAVA

Total questions: 10

Worksheet time: 30mins

Name
Class
Date
1.

Identify the abbreviation of AWT.

a)

Applet Windowing Toolkit

b)

Abstract Windowing Toolkit

c)

Absolute Windowing Toolkit

d)

None of the above

2.

Identify a method that can set or change the text in a Label.

a)

setText();

b)

getText();

c)

getEditableText();

d)

setSelectedText();

3.

Choose a CORRECT component in AWT that can refer to Figure 1.

a)

Label

b)

Frame

c)

TextField

d)

TextArea

4.

The following is NOT a valid button declaration

a)

JButton b = new JButton( );

b)

JButton b[ ] = new Jbutton[ ];

c)

ButtonTest application = new ButtonTest();

d)

Private JButton btnclose = new JButton(“Close”);

5.

Choose the TRUE statement to create CheckBox component by referring to Figure 2.

a)

Checkbox checkbox1 = new Checkbox(“Nasi Goreng”);

Checkbox checkbox2 = new Checkbox(“Roti Bakar”, true);

b)

Checkbox checkbox1 = new Checkbox(‘Nasi Goreng’);

Checkbox checkbox2 = new Checkbox(‘Roti Bakar’, true);

c)

Checkbox checkbox1 = new Checkbox[“Nasi Goreng”];

Checkbox checkbox2 = new Checkbox[“Roti Bakar”, true];

d)

Checkbox checkbox1 = new Checkbox[‘Nasi Goreng’];

Checkbox checkbox2 = new Checkbox[‘Roti Bakar’, true];

6.

Choose which of the following code snippets correctly changes the background color of a JFrame to blue?

a)

getContentPane().setColor(Color.BLUE);

b)

getContentPane().setBackground(Color.BLUE);

c)

setBackColor(Color.BLUE);

d)

setBackground(Color.BLUE);

7.

The name of the Swing class that is used for frames is called

a)

Frame

b)

JFrame

c)

Window

d)

SwingFrame

8.

Which of the following code snippets correctly sets the bounds of a JLabel named emailLabel to be at position (50, 250) with a width of 80 and a height of 25?

a)

A.      emailLabel.setBounds(250, 50, 80, 25);

b)

A.      emailLabel.setBounds(50, 250, 25, 80);

c)

A.      emailLabel.setBounds(50, 250, 80, 25);

d)

A.      emailLabel.setBounds(80, 25, 50, 250);

9.

Choose the BEST answer to load the MySQL driver.

a)

   Class.forName(com.mysql.jdbc.Driver);

b)

  Class.forName(“com.mysql.jdbc.Driver”);

c)

    Class.loadClass(com.mysql.jdbc.Driver);

d)

Class.loadClass(“com.mysql.jdbc.Driver);

10.

Refering to Figure 3, choose the method to execute the staement if PreparedStatement preparedStatement = PreparedStatement(); is given.

a)

preparedStatement.query()

b)

preparedStatement.execute()

c)

preparedStatement.executeUpdate()

d)

preparedStatement.executeQuery()