Java Reference
In-Depth Information
΢΢ Exercise R2.9. Find the errors in the following statements:
a. Rectangle r = (5, 10, 15, 20);
b. double width = Rectangle(5, 10, 15,
20).getWidth();
c. Rectangle r;
r.translate(15, 25);
d. r = new Rectangle();
r.translate("far, far away!");
΢ Exercise R2.10. Name two accessor methods and two mutator methods of
the Rectangle class.
΢΢ Exercise R2.11. Look into the API documentation of the Rectangle
class and locate the method
void add(int newx, int newy)
Read through the method documentation. Then determine the result of the
following statements:
Rectangle box = new Rectangle(5, 10, 20, 30);
box.add(0, 0);
If you are not sure, write a small test program or use BlueJ.
74
75
΢ Exercise R2.12. Find an overloaded method of the String class.
΢ Exercise R2.13. Find an overloaded method of the Rectangle class.
΢G Exercise R2.14. What is the difference between a console application and a
graphical application?
΢΢G Exercise R2.15. Who calls the paintComponent method of a
component? When does the call to the paintComponent method occur?
΢΢G Exercise R2.16. Why does the parameter of the paintComponent
method have type Graphics and not Graphics2D ?
Search WWH ::




Custom Search