Search Header Logo

Java Programming

Authored by undefined Nur Shamilla Binti Selamat

Computers

University

Used 4+ times

Java Programming
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax to create a button using Java Swing?

Button button = new Button();

JButton button = new JButton();

JLabel button = new JLabel();

JFrame button = new JFrame();

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax to add a button to a frame in Java GUI?

frame.add(button);

button.add(frame);

new Button().add(frame);

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax to set the text of a button in Java GUI?

button.setText("Hello, world!");

new Button("Hello, world!");

button.setLabel("Hello, world!");

button.setTitle("Hello, world!");

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax to create a label in Java GUI?

Label label = new Label();

JButton label = new JButton();

JFrame label = new JFrame();

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax to add a label to a frame in Java GUI?

frame.add(label);

label.add(frame);

new Label().add(frame);

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is not an exception handling keyword in Java?

try

catch

finally

if

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the try block in exception handling?

To execute a block of code that may throw an exception

To catch an exception and handle it

To execute a block of code that must be executed, regardless of whether an exception is thrown

To close all resources that were opened in the try block

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers