Home
Microsoft Office Index
Excel
Word
PowerPoint
A~Z Quizzes
Computer Programming
Typing Index
Typing Speed Test
English Lessons & Practice Grammar Tests
Excel 2016
Word 2016
A ~ Z of Tests & Quizzes Index Page
*
Health Tests
*
Personality Tests
*
Fun Tests
*
IQ Tests
*
EQ Tests
*
Computer Programming Languages
*
Java Tests
*
Multiplication Table Charts & Tests
Free Online Java Tests – JOptionPane Test- Java Language Programming
Java JOptionPane Test
Free Online Java Programming Tests
Java Language Programming
Test yourself on Java Programming JOptionPane – Importing javax.swing package to get an input using JOptionPane in the program.
10 Question Multiple Choice Quiz with Answers and Answer Explanations
1)
What is the java package that should be imported in the java program so that JOptionPane can be used?
a) javax.swing package.
b) java.io package.
c) javax.io package.
d) java.swing package.
2)
What is the correct import declaration of a java package for JOptionPane class to be used in the program?
a) import javax.swing.JOptionPane;
b) import javax.swing.*;
c) Both a and b
d) None of the above
3)
Which of the following is a correct statement that will display a dialog box with a message, a text field and an OK button as shown in the picture below?
a) String name = JOptionPane.showDialogInput(“Enter your name”);
b) String name = JOptionPane.showinputdialog(“Enter your name”);
c) String name = JOptionPane.showdialoginput(“Enter your name”);
d) String name = JOptionPane.showInputDialog(“Enter your name”);
4)
Which of the following is a correct statement that will display a dialog box with a message, a text field and an OK button as shown in the picture below?
a) JOptionPane.showDialogMessage(null, “Hello World!”);
b) JOptionPane.showMessageDialog(null, “Hello World!”);
c) JOptionPane.showmessagedialog(null, “Hello World!”);
d) JOptionPane.showdialogmessage(null, “Hello World!”);
5)
Which of the following is a correct statement that accepts a whole number value using JOptionPane?
a) String number = Integer.parseInt(JOptionPane.showInputDialog(“Enter a number:”));
b) int number = JOptionPane.showInputDialog(“Enter a number:”);
c) int number = Integer.parseInt(JOptionPane.showInputDialog(“Enter a number:”));
d) None of the above
6)
Which is the correct statement that displays a whole number value of variable num using JOptionPane?
a) JOptionPane.showMessageDialog(null, “The number is “+num);
b) JOptionPane.showMessageDialog(null, “The number is num”);
c) JOptionPane.showMessageDialog(null, “The number is “+num”)
d) JOptionPane.showMessageDialog(null, “The number is “num);
7)
Which of the following is a correct statement that accepts any number value using JOptionPane?
a) int number = Integer.parseInt(JOptionPane.showInputDialog(“Enter a number:”));
b) String number = Integer.parseInt(JOptionPane.showInputDialog(“Enter a number:”));
c) float number = JOptionPane.showInputDialog(“Enter a number:”);
d) float number = Float.parseFloat(JOptionPane.showInputDialog(“Enter a number:”));
8)
What is the symbol needed so that all the classes in the javax.swing package can be used in the java program?
a) The semicolon ; symbol.
b) The asterisk * symbol.
c) The percent % symbol.
d) The colon : symbol.
9)
In the given statement: float number = Float.parseFloat(JOptionPane.showInputDialog(“Enter a number:”)); What is the default data type of the input in JOptionPane?
a) float
b) char
c) String
d) int
10)
What kind of interface is being used in the JOptionPane?
a) graphical user interface
b) menu driven interface
c) command line interface
d) none of the above
Please leave this field empty.
A to Z of Tests & Quizzes
IQ Tests
EQ Tests
Fun Tests
Personality Tests
Health Tests
Multiplication Table Charts
Printable Free Download
2 & 3 Times Tables Quiz
3 & 4 Times Tables Quiz
4 & 5 Times Tables Quiz
5 & 6 Times Tables Quiz
6 & 7 Times Tables Quiz
8 & 9 Times Tables Quiz
Computer Programming Languages