Deck 2: Console Input and Output

ملء الشاشة (f)
exit full mode
سؤال
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
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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
سؤال
Efficiency is lost in importing the entire package instead of importing the classes you use.
سؤال
The Scanner class has a method next that allows an entire line of string text to be read.
سؤال
Write Java statements to apply currency formatting to the number 100.Indicate the package you need to import.
سؤال
Every Java program automatically imports the java.util package.
سؤال
Which statement or group of statements produces the output: Java programming is fun!
(a)System.out.print(Java programming); System.out.print(is fun!);
(b)System.out.println(Java 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!");
سؤال
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.
سؤال
The Java method printf is based on the ________ language.
(a)Pascal
(b)C++
(c)C
(d)ADA
سؤال
Standard code libraries in Java are called:
(a)Methods
(b)Classes
(c)Packages
(d)Statements
سؤال
Echoing input is good programming practice because it can reveal problems in the input.
سؤال
What Java package includes the class Scanner?
(a)awt
(b)swing
(c)io
(d)util
سؤال
Write a Java statement to display your name in the console window.
سؤال
The method printf is used the same way as the method println but has the added feature that allows you to add formatting instructions.
سؤال
The statement: System.out.printf("%6.2f",597.7231); displays:
(a)597.723
(b)597.72
(c)000597.72
(d)None of the above
سؤال
What does the following code output?
DecimalFormat percent = new DecimalFormat("0.00%");
System.out.println(percent.format(0.308));
(a)3.080%
(b)30.80%
(c))0308%
(d)308.0%
سؤال
What does the following code output?
DecimalFormat dfQuestion = new DecimalFormat("#0.##E0");
System.out.println(dfQuestion.format(12.7896987));
(a)12.79E0
(b)12.8E0
(c)1.28E1
(d))13E2
سؤال
The new line character is represented as '\n'.
سؤال
The printf method can be used to output multiple formatted values.
سؤال
Write ONE Java statement to display your first and last name on two separate lines.
سؤال
What does it mean to prompt the user?
سؤال
Write a Java statement to create and initialize a Scanner object named input.
سؤال
What do the format specifiers d,f,e,g,s and c represent?
سؤال
Write a Java program to create and display 57.32% using the DecimalFormat class.Include the necessary import statement to use the DecimalFormat class.
سؤال
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?
سؤال
Write a complete Java console application that prompts the user for two numbers,multiplies the numbers,and then displays the result to the user.
سؤال
Why is echoing user input a good programming practice?
سؤال
What is whitespace and why is it import when reading input from the keyboard using the Scanner class?
سؤال
Explain the significance of the pattern string used by the DecimalFormat object,and give an example of a valid pattern.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/29
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 2: Console Input and Output
1
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
A
2
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
D
3
Efficiency is lost in importing the entire package instead of importing the classes you use.
False
4
The Scanner class has a method next that allows an entire line of string text to be read.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
5
Write Java statements to apply currency formatting to the number 100.Indicate the package you need to import.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
6
Every Java program automatically imports the java.util package.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which statement or group of statements produces the output: Java programming is fun!
(a)System.out.print(Java programming); System.out.print(is fun!);
(b)System.out.println(Java 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!");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
8
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
9
The Java method printf is based on the ________ language.
(a)Pascal
(b)C++
(c)C
(d)ADA
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
10
Standard code libraries in Java are called:
(a)Methods
(b)Classes
(c)Packages
(d)Statements
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
11
Echoing input is good programming practice because it can reveal problems in the input.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
12
What Java package includes the class Scanner?
(a)awt
(b)swing
(c)io
(d)util
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
13
Write a Java statement to display your name in the console window.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
14
The method printf is used the same way as the method println but has the added feature that allows you to add formatting instructions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
15
The statement: System.out.printf("%6.2f",597.7231); displays:
(a)597.723
(b)597.72
(c)000597.72
(d)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
16
What does the following code output?
DecimalFormat percent = new DecimalFormat("0.00%");
System.out.println(percent.format(0.308));
(a)3.080%
(b)30.80%
(c))0308%
(d)308.0%
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
17
What does the following code output?
DecimalFormat dfQuestion = new DecimalFormat("#0.##E0");
System.out.println(dfQuestion.format(12.7896987));
(a)12.79E0
(b)12.8E0
(c)1.28E1
(d))13E2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
18
The new line character is represented as '\n'.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
19
The printf method can be used to output multiple formatted values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
20
Write ONE Java statement to display your first and last name on two separate lines.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
21
What does it mean to prompt the user?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
22
Write a Java statement to create and initialize a Scanner object named input.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
23
What do the format specifiers d,f,e,g,s and c represent?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
24
Write a Java program to create and display 57.32% using the DecimalFormat class.Include the necessary import statement to use the DecimalFormat class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
25
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?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
26
Write a complete Java console application that prompts the user for two numbers,multiplies the numbers,and then displays the result to the user.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
27
Why is echoing user input a good programming practice?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
28
What is whitespace and why is it import when reading input from the keyboard using the Scanner class?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
29
Explain the significance of the pattern string used by the DecimalFormat object,and give an example of a valid pattern.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.