Console Input and Output - Lecture Notes | CSC 3405, Study notes of Computer Science

Material Type: Notes; Professor: Wei; Class: Intro Computer Programming; Subject: Computer Science; University: Saint Joseph's University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/19/2009

koofers-user-7ao
koofers-user-7ao 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 2
Console Input and Output
Multiple Choice
1) 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
2) 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!”);
2) 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
3) The statement: System.out.printf("%6.2f", 597.7231); displays:
(a) 597.723
(b) 597.72
(c) 000597.72
(d) None of the above
pf3

Partial preview of the text

Download Console Input and Output - Lecture Notes | CSC 3405 and more Study notes Computer Science in PDF only on Docsity!

Chapter 2

Console Input and Output

 Multiple Choice

  1. 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
  2. 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!”);
  3. 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
  4. The statement: System.out.printf("%6.2f", 597.7231); displays: (a) 597. (b) 597. (c) 000597. (d) None of the above
  1. The Java method printf is based on the ________ language. (a) Pascal (b) C++ (c) C (d) ADA
  2. 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.
  3. Standard code libraries in Java are called: (a) Methods (b) Classes (c) Packages (d) Statements
  4. 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%
  5. What does the following code output? DecimalFormat dfQuestion = new DecimalFormat("#0.##E0"); System.out.println(dfQuestion.format(12.7896987));