Java Reference
In-Depth Information
14. System.in and System.out .
15. Yes, it works. Static methods can access static fields of the same class. But
it is a terrible idea. As your programming tasks get more complex, you will
want to use objects and classes to organize your programs.
16. The scope of amount is the entire deposit method. The scope of
newBalance starts at the point at which the variable is defined and
extends to the end of the method.
17. It starts at the beginning of the class and ends at the end of the class.
18. (a) No; (b) Yes; (c) Yes; (d) No
19. NoÈŒyou simply use fully qualified names for all other classes, such as
java.util.Random and java.awt.Rectangle .
20. /home/me/cs101/hw1/problem1 or, on Windows,
c:\me\cs101\hw1\problem1 .
21. Here is one possible answer, using the JUnit 4 style.
public class EarthquakeTest
{
@Test public void testLevel4()
{
Earthquake quake = new Earthquake(4);
Assert.assertEquals("Felt by many people, no
destruction",
quake.getDescription());
}
}
22. It is a tolerance threshold for comparing floating-point numbers. We want
the equality test to pass if there is a small roundoff error.
385
Search WWH ::




Custom Search