ch03ExSol - Chapter 3 Review Exercise Solutions R3.1 An...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 3 Review Exercise Solutions R3.1 An interface is the public view of a class. It tells a program using the class what the functionality is, and how to use it. It does not disclose any details on how things are actually done. An implementation of a class is the actual code for accomplishing the tasks. R3.2 Encapsulation is the process of hiding implementation details while publishing an interface for programmers to use. If you hide the implementation details, you can diagnose errors and make changes and improvements to the implementation of a class without disrupting the work of programmers who use the class. R3.3 The private reserved word prevents a programmer using the class from manipulating instance variables except through the methods of that class. A programmer must use the public interface—the public methods that access or modify the instance variables—to change them. R3.4 private String value; or a more descriptive name private String grade; R3.5 Represent the time as one entire string value, example “8:35 a.m.” private String value; or as individual components private int hour; private int minute; private String meridian; R3.6 The programmers using the Time class do not have to do anything. That is the purpose of encapsulation and using a public interface. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
R3.7 That depends on what you intend for the Counter class to do. Normally, no, you would not provide a setValue method because the counter, as described, should always start at zero. It may be desirable to add a reset method. If there was a reason to start a counter at a
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/07/2010 for the course JAVA 153 taught by Professor Silou during the Spring '10 term at Golden West College.

Page1 / 5

ch03ExSol - Chapter 3 Review Exercise Solutions R3.1 An...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online