Java Reference
In-Depth Information
19. Write Java statements that accomplish the following:
a. Outputs the newline character.
b. Outputs the tab character.
c. Outputs a double quotation mark.
20. Which of the following are correct Java statements?
a. System.out.println("Hello There!");
b. System.out.println("Hello");
(" There!");
c. System.out.println("Hello" +
" There!");
d. System.out.println('Hello There!');
21. Give meaningful identifiers for the following variables:
a. A variable to store the first name of a student.
b. A variable to store the discounted price of an item.
c. A variable to store the number of juice bottles.
d. A variable to store the number of miles traveled.
e. A variable to store the highest test score.
22. Write Java statements to do the following:
a. Declare int variable num1 and num2 .
b. Prompt the user to input two numbers.
c. Input the first number in num1 and the second number in num2 .
d. Output num1 , num2 , and 2 times num1 minus num2 . Your output must
identify each number and the expression.
23. The following program has syntax errors. Correct them. On each successive
line, assume that any preceding error has been corrected. After you have
corrected the syntax errors, type and compile the program to check if all
errors have been found.
public class Exercise23
{
2
static final int SECRET_NUM = 11,213;
static final PAY_RATE = 18.35
public void main(String[] arg)
{
int one, two;
double first, second;
one = 18;
two = 11;
first = 25;
second = first * three;
Search WWH ::




Custom Search