Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Solution Manual for Starting Out with Java: From Control Structures through Objects, 5/E 5th

Solution Manual for Starting Out with Java: From


Control Structures through Objects, 5/E 5th Edition :
0132989999

To download the complete and accurate content document, go to:


https://testbankbell.com/download/solution-manual-for-starting-out-with-java-from-con
trol-structures-through-objects-5-e-5th-edition-0132989999/

Visit TestBankBell.com to get complete for all chapters


Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e 1

Starting Out with Java - From Control Structures through Objects


Answers to Review Questions

Chapter 8

Multiple Choice and True/False

1. c
2. c
3. a
4. c
5. b
6. c
7. d
8. b
9. c
10. a
11. b
12. False
13. False
14. True
15. False

Find the Error

1. The static method setValues cannot refer to the non-static fields x and y.
2. You cannot use the fully-qualified names of enum constants in the case
expressions.

Algorithm Workbench

1.

a) public String toString()


{
String str;
str = "Radius: " + radius +
" Area: " + getArea();
return str;
}

b) public boolean equals(Circle c)


{
boolean status;

if (c.getRadius() == radius)
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e 2

status = true;
else
status = false;

return status;
}

c) public boolean greaterThan(Circle c)


{
boolean status;

if (c.getArea() > getArea())


status = true;
else
status = false;

return status;
}

2.
a) 3
b) 3
c) 1
d) 0
e) Thing.putThing(5);

3. enum Pet { DOG, CAT, BIRD, HAMSTER }

Short Answer

1. Access a non-static member.


2. They can be called directly from the class, as needed. They can be used to create
utility classes that perform operations on data, but have no need to collect and
store data.
3. When a variable is passed as an argument, a copy of the variable's contents is
passed. The receiving method does not have access to the variable itself. When an
object is passed as an argument, a reference to the object (which is the object's
address) is passed. This allows the receiving method to have access to the object.
4. The default equals method returns true if the memory addresses of the two
objects being compared are the same.
5. It means that an aggregate relationship exists. When an object of class B is a
member of class A, it can be said that class A "has a" class B object.
6. The program will crash.
7. It is not advisable because it will allow access to the private fields. The exception
to this is when the field is a String object. This is because String objects are
immutable, meaning that they cannot be changed.
Solution Manual for Starting Out with Java: From Control Structures through Objects, 5/E 5th

Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e 3

8. The key word this is the name of a reference variable that an object can use to
refer to itself. It is available to all non-static methods.
9. a) Color
b) Color.RED, Color.ORANGE, Color.GREEN, Color.BLUE
c) Color myColor = Color.BLUE;
10. a) POODLE
BOXER
TERRIER
b) 0
1
2
c) BOXER is NOT greater than TERRIER

11. When there are no references to it.

Visit TestBankBell.com to get complete for all chapters

You might also like