java chap 2
keywords
boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break throw implements short public default try import double static for catch synchronized int new continue finally const long this do transient goto abstract super extends instanceof null
System.out.println(userAge + " \nis " + userName + "'s age.");
22 is Tom's age.
How many times will the while loop that follows be executed if months has a value of 5? int i = 1; while (i < months) { futureValue = futureValue * (1 + monthlyInterestRate); i = i+1;
4
Which of the following is a valid class name? Customer-Maintenance 2004YearEndApp CustomerMaintApp Numeric#Validator
CustomerMaintApp
According to standard naming conventions, which of the following is a typical class name? $Calculate calculateTotal Product product
Product
rules for naming indentifier
Start each identifier with a letter, underscore, or dollar sign. Use letters, dollar signs, underscores, or digits for subsequent characters. • Use up to 255 characters. • Don't use Java keywords.
recommendations for naming class
Start every word within a class name with an initial cap. • Each class name should be a noun or a noun that's preceded by one or more adjectives.
rules for naming class
Start the name with a capital letter. • Use letters and digits only. • Follow the other rules for naming an identifier
You can use relational operators to
compare numeric variables
You typically use comments in a Java application to
describe code that is difficult to understand
Which of the following is a valid statement for declaring and initializing a double variable named length to a starting value of 120?
double length = 120.0;
Based on the naming recommendations in the book, which of the following is a good identifier for a variable that will be used to hold an employee's phone number? employee_phone_number emphonumber employeePhoneNumber EmployeePhoneNumber
employeePhoneNumber
The double data type can be used to store
floating point numbers
Which package is automatically available to all Java programs?
java.lang
What does testing an application entail?
running it to see if it works correctly
Which of the following is a valid variable name? salesTax input-string 25Percent double
salesTax
If a class contains a main() method, that method is executed
when the class is run
The int data type can be used to store
whole numbers only
Block scope means that a variable
xsewd???can't be used outside of the statement that it's declared in