Java TOPIC 13 – TEST I REVIEW DETAILS & REVIEW DETAILS The test
covers both Units 0 and 1. All
notes. All work. All class discussion is fair game. Minor
programming errors will not count against you. The Java template
will be provided for you. So you do not have to memorize the method prototype for
the main function. REVIEW QUESTION 1 Go over the
following terms and make sure that you can define each one. Some will appear as part of multiple choice questions on the test.
QUESTION 2 Which variable
names follow the correct convention? 2daysDate Length plentyOfFun fun IWILLFAIL
Solve the
following arithmetic expressions. a)
int
a = 7 + 18 - 4; b)
int
b = 43 % 6; c)
int
c = 2 + 4 * 3; d)
int
d = 6 - 3 * 2; e)
int
e = 7 / 2; f)
double
f = 9 / 2; g)
double
g = 8 % 3 + 2; h)
double
h = 3 * 6 % 5; i)
double
i = (int)6.5 * 2; j)
double
j = Math.sqrt(81); k)
double
k = Math.pow(3,2); l)
double
l = Math.pow(1+1, 3); m)
double
m = Math.ceil(2.2 * 2); n)
double
n = Math.round(4.3); o)
double
o = Math.max(2*4,6+3); p)
double
p = Math.min(Math.floor(4.2), Math.ceil(4.2)); q)
double
q = 1.0 / (1.5 + 0.5); r)
double
r = Math.pow(Math.max(4,3), Math.min(2,3)); s)
double
s = Math.cbrt(27);
Answer the
following: a)
Consider
a Point class that has two data fields (instance variables) called x and
y. Write the statements required to
create a Point object name p and give it the coordinates (6,2). b)
Write
the Sword class. It has a String data
field for its name and two int data fields for it's accuracy and damage. c)
Consider
the Sword class from b. Write the
statements needed to create the sword object called Excalibur that has an
accuracy of 9 and a damage of 12. d)
Consider the following function from NOOPDraw: e)
The function call NOOPDraw.drawRectangle(0,0,100,50)
is creating a rectangle that actually needs to be moved to the right by 40
pixels. Which of the following would
be the corrected statement: f)
The function call NOOPDraw.drawEllipse(200,240,100,100)
is creating a circle that actually needs to be moved up by 10 pixels. Which of the following would be the
corrected statement:
QUESTION 5 – SMALL
PROGRAMS Write the
following programs. a)
Write
the program that asks the user for their first, middle and last names. It then greets the user by saying
"Hello name". Make sure you have appropriate spacing. You want to review using the Scanner object
for this. b)
Ask
the user for their age. Output the
user’s year of birth. The output
should look like this:
35 If your birthday passed this year,
you were born in 1978. in 1977. c)
Ask
the user for the name of an item, its price and the tax rate (3 inputs in
total). The program should output a
sentence with the items name and it’s full price after
taxes. |
|||
Good luck! You’ll need it! Just kidding! No I’m not. J |
|||
|