Download presentation
1
PreAP Computer Science Quiz 06.01- 04
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 30 seconds per question.
2
Title the quiz as shown below The quiz starts in ONE minute.
Name Period Date Quiz 1. 7. 2. 8. 3. 9. 4. 10. 5. 11. 6. EC.
3
Question 01 In the statement int x; What is int ? a variable
a data type a class an object
4
Question 02 In the statement int x; What is x ? a variable a data type
a class an object
5
Question 03 In the statement Bank tom = new Bank(5000.0);
Which is the class? Bank tom new 5000.0
6
Question 04 In the statement Bank tom = new Bank(5000.0);
Which is the object? Bank tom new 5000.0
7
Question 05 In the statement Bank tom = new Bank(5000.0);
Which is the parameter? Bank tom new 5000.0
8
Question 06 In the statement Bank tom = new Bank(5000.0);
Which word is responsible for creating a new object? Bank tom new 5000.0
9
Question 07 The DecimalFormat class has the ability to
(a) round off decimal numbers to a specified number of digits. (b) format numbers with leading zeroes. (c) insert commas (d) insert dollar signs. (e) do all of the above.
10
Question 8 What is the output of this program segment? DecimalFormat output; output = new DecimalFormat("0000"); System.out.println(output.format(1)); System.out.println(output.format(12)); System.out.println(output.format(123)); (a) 1 12 123 (b) 001 012 (c) 0001 0012 0123 (d) 1000 1200 1230 (e) Error
11
(a) 1 12 123 1234 (b) 001 012 (c) 0001 0012 0123 (d) (e) Error
Question 9 What is the output of this program segment? DecimalFormat output; output = new DecimalFormat("000"); System.out.println(output.format(1)); System.out.println(output.format(12)); System.out.println(output.format(123)); System.out.println(output.format(1234)); (a) 1 12 123 1234 (b) 001 012 (c) 0001 0012 0123 (d) (e) Error
12
output = new DecimalFormat("0.00");
Question 10 Which of the statements below can replace the missing statement so the program will display $3.14 ? DecimalFormat output; // missing statement System.out.println(output.format(Math.PI)); output = new DecimalFormat("0.00"); output = new DecimalFormat("0,000"); output = new DecimalFormat("$0.00"); output = new DecimalFormat("$0,000"); output = new DecimalFormat("$0,000.00");
13
output = new DecimalFormat("0.00");
Question 11 Which of the statements below can replace the missing statement so the program will display 1,234,567,890 ? DecimalFormat output; // missing statement int num = ; System.out.println(output.format(num)); output = new DecimalFormat("0.00"); output = new DecimalFormat("0,000"); output = new DecimalFormat("$0.00"); output = new DecimalFormat("$0,000"); output = new DecimalFormat("$0,000.00");
14
Extra Credit (a) 123456789.988 (b) 123456789.987 (c) 9.988 (d) 9.987
What is the output of the following program segment? double number = DecimalFormat output = new DecimalFormat("0.000"); System.out.println(output.format(number)); (a) (b) (c) (d) (e) (f) 14
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.