Deck 2: Console Input and Output

Full screen (f)
exit full mode
Question
The printf method can be used to output multiple formatted values.
Use Space or
up arrow
down arrow
to flip the card.
Question
Write ONE Java statement to display your first and last name on two separate lines.
Question
Which statement or group of statements produces the output: Java programming is fun!

A)System.out.printJava programming); System.out.printis fun!);
B)System.out.printlnJava programming is fun!);
C)System.out.println"Java programming"); System.out.println" is fun!");
D)System.out.print"Java programming") System.out.println" is fun!");
Question
What does the following code output? DecimalFormat percent = new DecimalFormat"0.00%");
System.out.printlnpercent.format0.308));

A)3.080%
B)30.80%
C).0308%
D)308.0%
Question
Efficiency is lost in importing the entire package instead of importing the classes you use.
Question
The statement: System.out.printf"%6.2f",597.7231);displays:

A)597.723
B)597.72
C)000597.72
D)None of the above
Question
The Java method printf is based on the ________ language.

A)Pascal
B)C++
C)C
D)ADA
Question
If a hyphen is added after the % in a format specifier,the output will be _________.

A)Left justified
B)Right justified
C)Centered
D)None of the above
Question
The new line character is represented as '\n'.
Question
Echoing input is good programming practice because it can reveal problems in the input.
Question
The class NumberFormat allows you to specify a constant representing which country's currency format should be used.To use this constant you must import:

A)java.util.Locale
B)java.util.Currency
C)java.util.Properties
D)None of the above.
Question
Write Java statements to apply currency formatting to the number 100.Indicate the package you need to import.
Question
The method printf is used the same way as the method println but has the added feature that allows you to add formatting instructions.
Question
Valid arguments to the System.out object's println method include:

A)"Anything with double quotes"
B)String variables
C)Variables of type int
D)All of the above
Question
What Java package includes the class Scanner?

A)awt
B)swing
C)io
D)util
Question
Standard code libraries in Java are called:

A)Methods
B)Classes
C)Packages
D)Statements
Question
What does the following code output? DecimalFormat dfQuestion = new DecimalFormat"#0.##E0");
System.out.printlndfQuestion.format12.7896987));

A)12.79E0
B)12.8E0
C)1.28E1
D).13E2
Question
The Scanner class has a method next that allows an entire line of string text to be read.
Question
Write a Java statement to display your name in the console window.
Question
Every Java program automatically imports the java.util package.
Question
Explain the significance of the pattern string used by the DecimalFormat object,and give an example of a valid pattern.
Question
What do the format specifiers d,f,e,g,s and c represent?
Question
If there is no loss of efficiency in importing an entire Java package instead of importing only classes you use into your program,why would you not just import the entire package?
Question
Why is echoing user input a good programming practice?
Question
Write a complete Java console application that prompts the user for two numbers,multiplies the numbers,and then displays the result to the user.
Question
Write a Java program to create and display 57.32% using the DecimalFormat class.Include the necessary import statement to use the DecimalFormat class.
Question
Write a Java statement to create and initialize a Scanner object named input.
Question
What does it mean to prompt the user?
Question
What is whitespace and why is it import when reading input from the keyboard using the Scanner class?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/29
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: Console Input and Output
1
The printf method can be used to output multiple formatted values.
True
2
Write ONE Java statement to display your first and last name on two separate lines.
System.out.print"Wally\nWonders");
3
Which statement or group of statements produces the output: Java programming is fun!

A)System.out.printJava programming); System.out.printis fun!);
B)System.out.printlnJava programming is fun!);
C)System.out.println"Java programming"); System.out.println" is fun!");
D)System.out.print"Java programming") System.out.println" is fun!");
D
4
What does the following code output? DecimalFormat percent = new DecimalFormat"0.00%");
System.out.printlnpercent.format0.308));

A)3.080%
B)30.80%
C).0308%
D)308.0%
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
5
Efficiency is lost in importing the entire package instead of importing the classes you use.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
6
The statement: System.out.printf"%6.2f",597.7231);displays:

A)597.723
B)597.72
C)000597.72
D)None of the above
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
7
The Java method printf is based on the ________ language.

A)Pascal
B)C++
C)C
D)ADA
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
8
If a hyphen is added after the % in a format specifier,the output will be _________.

A)Left justified
B)Right justified
C)Centered
D)None of the above
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
9
The new line character is represented as '\n'.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
10
Echoing input is good programming practice because it can reveal problems in the input.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
11
The class NumberFormat allows you to specify a constant representing which country's currency format should be used.To use this constant you must import:

A)java.util.Locale
B)java.util.Currency
C)java.util.Properties
D)None of the above.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
12
Write Java statements to apply currency formatting to the number 100.Indicate the package you need to import.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
13
The method printf is used the same way as the method println but has the added feature that allows you to add formatting instructions.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
14
Valid arguments to the System.out object's println method include:

A)"Anything with double quotes"
B)String variables
C)Variables of type int
D)All of the above
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
15
What Java package includes the class Scanner?

A)awt
B)swing
C)io
D)util
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
16
Standard code libraries in Java are called:

A)Methods
B)Classes
C)Packages
D)Statements
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
17
What does the following code output? DecimalFormat dfQuestion = new DecimalFormat"#0.##E0");
System.out.printlndfQuestion.format12.7896987));

A)12.79E0
B)12.8E0
C)1.28E1
D).13E2
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
18
The Scanner class has a method next that allows an entire line of string text to be read.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
19
Write a Java statement to display your name in the console window.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
20
Every Java program automatically imports the java.util package.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
21
Explain the significance of the pattern string used by the DecimalFormat object,and give an example of a valid pattern.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
22
What do the format specifiers d,f,e,g,s and c represent?
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
23
If there is no loss of efficiency in importing an entire Java package instead of importing only classes you use into your program,why would you not just import the entire package?
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
24
Why is echoing user input a good programming practice?
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
25
Write a complete Java console application that prompts the user for two numbers,multiplies the numbers,and then displays the result to the user.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
26
Write a Java program to create and display 57.32% using the DecimalFormat class.Include the necessary import statement to use the DecimalFormat class.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
27
Write a Java statement to create and initialize a Scanner object named input.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
28
What does it mean to prompt the user?
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
29
What is whitespace and why is it import when reading input from the keyboard using the Scanner class?
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 29 flashcards in this deck.