This website is preserved for historical and scholarly reference and is no longer actively maintained.
QUIZ 6
September 3, 1997
#1. The Java text explains the following shorthand assignment statement:
a) Rewrite this statement using the instructions for program style given in class (but still using the shorthand += notation).
b) Rewrite this statement without using the shorthand notation (i.e., use the = assignment operator, not +=).
#2. Is the following code correct? Justify your answer.
Circle c;
...
System.out.print(c);
#3. Suppose class Employee contains only the following methods
Employee(n,x)Constructs an employee with name n and salary s.
e.getName()Returns the name of e
e.getSalary()Returns the salary of e
e.setSalary(s)Sets salary of e to s
after
Employee harry = new Employee ("Hacker, Harry", 45000.00);
a) Write code to give Harry Hacker a $150 raise.
b) Identify the error in the following code.
harry.setName ("Hacker, Harry H.");