Page 134 - Introduction to Programming with Java: A Problem Solving Approach
P. 134
100 Chapter 3 Java Basics §3.3 Comments and Readability
3. Why does source code have comments?
§3.4 The Class Heading
4. For a file with a public class, the program’s filename must match the program’s class name except that the
filename has a .java extension added to it. (T / F)
5. Standard coding conventions dictate that class names start with a lowercase first letter. (T / F)
6. In Java, the case of a character does matter. (T / F)
§3.5 The main Method’s Heading
7. A program’s start-up method, main, should be in a class that is public. (T / F)
8. The main method itself must be public. (T / F)
9. From your memory alone (don’t look for the answer in the book), write the main method heading.
§3.6 Braces
10. Identify two types of groupings that must be enclosed in braces.
§3.7 System.out.println
11. From your memory alone (don’t look for the answer in the book), write the statement that tells the computer
to display this string of text:
Here is an example
§3.9 Identifiers
12. List all of the types of characters that may be used to form an identifier.
13. List all of the types of charactAerspthat mgaoy be uPsedDaFs the fiErsnt charactner ocf aen ridentifier.
§3.10 Variables
14. You should abbreviate variable names by omitting vowels, in order to save space. (T / F) 15. Why is it good practice to use a separate line to declare each separate variable?
§3.11 Assignment Statements
16. There must be a semicolon after every assignment statement. (T / F)
§3.12 Initialization Statements
17. Initialization “kills two birds with one stone”. What are the “two birds”?
§3.13 Numeric Data Types—int, long, float, double
18. The most appropriate type to use for financial accounting is ——————.
19. For each statement, specify true or false:
a) 1234.5 is a floating-point number. (T / F) b) 1234 is a floating-point number. (T / F)
c) 1234. is a floating-point number. (T / F)
20. If you try to assign an int value into a double variable, the computer automatically makes the conversion
without complaining, but if you try to assign a double value into an int variable, the compiler generates an error. Why?
§3.14 Constants
21. For each statement, specify true or false:
a) 0.1234 is a float. (T / F) b) 0.1234f is a float. (T / F)