Beruflich Dokumente
Kultur Dokumente
1) (10 points, 1 point each) Match each of the terms on the left by choosing the upper case letter of the best
answer on the right and putting it next to the lower case letter in the space provided.
2) (10 points, 1 point each) Match each of the notations or keywords on the left by choosing the upper case
letter of the best answer on the right and putting it next to the lower case letter in the space provided.
c. ; C. increment a variable
i. public static void I. used for reading input from the keyboard
1010 110101 35
4) (20 points, 2 points each) Find the value of each of the following expressions:
a. 2 + 3 * 5
b. 2 * 5 + 3
c. 2 / 3 + 3 / 2
d. 23 % 6
e. 5 / 3 + 7 / 2.0 - 6 / 5
f. 24 % 3 * 3 - 7.0
g. 3.2 * 2.0 / 4 + 5
i. 4/3 * 3.14 * 2
j. 37 / 17.0 * 17
int x = 5;
int y = 8;
x = x + y;
System.out.println("The values are "+ x + " and " + y);
y = 9;
Name
System.out.println("abc");
System.out.print("def");
System.out.println("xyz");
int j;
for (int i=0; i<=11; i = i + 3) {
j = i - 3;
System.out.println("The value is "+ i + j);
}
8) (5 points) What is printed when the printAll method is called?
9) (10 points) Write a complete program that prints your full name.
10) (10 points) Suppose that CONSOLE has already been declared and initialized by:
public static final Scanner CONSOLE = new Scanner(System.in);
Write a program segment that prompts the user for his age in years, and prints out the value entered with an
appropriate message.
11) (5 points) Write a method that uses a for loop to print the integers from 4 to 15 all on one line, separated by
blanks.
The output should look like: 4 5 6 7 8 9 10 11 12 13 14 15
12) (5 points) Suppose you have already written each of the following three methods printOneBlank(),
printOneStar(), and printOneNewline(), and these each do the obvious thing.
Write a code segment that uses nested for loops to print the following pattern. Your code segment may use
the above methods but may not use System.out.print or System.out.println.
**
* *
* *
* *
* *
* *
Exactly 6 lines should be printed and the first * in the last line is in column 1.
Do not write the methods printOneBlank(), printOneStar(), and printOneNewline().
Hint: In line k, write a formula for:
a) the number of leading blanks
b) the number of blanks between the *’s