Download PreAPCS Exposure Java Exercises 06.01

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
PreAPCS Exposure Java Exercises 06.01- 04 Date:
Name:
Period:
1.
What kind of methods did you use in chapters 4 and 5?
2.
An _______ stores more than data, because data by itself lacks all _______.
3.
What does the word class imply?
4.
List 7 Math class methods.
5.
List 2 Math class data members.
6.
Methods of the Math class are called what type of methods?
7.
If Bank is a class and checkingDeposit is an object method of the Bank class, then the statement
Bank.checkingDeposit(1000); is NOT a proper statement. Rewrite this statement properly to deposit
$1000 in your checking account.
8.
To use an object method, an _______ must first be created.
Questions 9-12 refer to the following examples from the
GridWorld Case Study. In each example, you need to list
how many classes and how many objects are being shown.
9.
Number of classes:
Number of objects:
Exposure Java 2013, PreAPCS Edition
Exercises 06.01-04
Page 1
05-22-13
10.
Number of classes:
Number of objects:
11.
Number of classes:
Number of objects:
12.
Number of classes:
Number of objects:
Exposure Java 2013, PreAPCS Edition
Exercises 06.01-04
Page 2
05-22-13
13.
What was the primary motivation of introducing graphics programming back in Chapter IV?
Refer to program Java0601.java for question 14.
14.
What is wrong with this program?
Refer to program Java0602.java for questions 15 through 17.
15.
How does this program fix the problem of previous program?
16.
In the statement Bank tom; what is Bank and what is tom?
17.
What does the statement tom = new Bank(); do?
18.
For right now, the author wants you to think of constructing an object as a combination of what 2
things?
19.
Objects are usually created with some initial value or values. In the case of the Bank class objects are
created with a $0.00 balance. What special methods make this possible?
20.
Why would a class have more than one constructor?
Refer to program Java0603.java for questions 21 through 23.
21.
Write 2 lines of Java code that will create a Bank object for yourself and initialize both your checking
and your savings account to $1 million.
22.
Write 1 line of Java code that will make a $250,000 deposit in your checking account.
23.
Write 1 line of Java code that will make a $500,000 deposit in your savings account.
24.
Rewrite these two statements as one:
String name; name = “John”;
25.
Rewrite these two statements as one:
Bank john; john = new Bank();
Exposure Java 2013, PreAPCS Edition
Exercises 06.01-04
Page 3
05-22-13
Refer to program Java0604.java for questions 26 and 27.
26.
Write 1 line of Java code that will make a $150,000 withdrawal from your checking account.
27.
Write 1 line of Java code that will make a $400,000 withdrawal from your savings account.
28.
Which class lets you control the output appearance of numbers?
Refer to program Java0605.java for questions 29 and 30.
29.
Write 1 line of Java code that will create a DecimalFormat object that will be used to display numbers
with up to 3 digits.
30.
Write 1 line of Java code that will use the object you created in the previous question to display the
number “23” as “023”.
Refer to program Java0606.java for question 31.
31.
If the following line of Java code was added to the program, what would be its output?
System.out.println(output.format(1234567890));
Refer to program Java0607.java for questions 32 through 34.
32.
Does the DecimalFormat object always need to be called output?
33.
If the following line of Java code was added to the program, what would be its output?
System.out.println(money.format(Math.PI));
34.
If the following line of Java code was added to the program, what would be its output?
System.out.println(money.format(345.678));
Refer to program Java0608.java for questions 35.
35.
Look at the output of this statement: System.out.println(output4.format(Math.PI));
The output is 3.1416. If we look at the next output, it is 3.1415 9.
Why is the 4th digit a 5 in one line and a 6 in the next?
Exposure Java 2013, PreAPCS Edition
Exercises 06.01-04
Page 4
05-22-13