Problems 1-3 were simply Code Warrior exercises.
Solutions for problems 4 to 8:
4. [5 pts]
a. (Choose 1) Is the Java Virtual
Machine hardware or software?
b. (Short answer) What does it do?
(I'm looking for about 1 sentence here).
Ans:
a. The Java Virtual Machine
is software.
b. It is an abstraction layer
that acts as a separate machine running the compiled Java bytecodes independent
of the operating system running on the computer.
5. [5 pts] Suppose I built my own computer out of parts, and I have an operating system for it that runs fine (but I'm not going to tell you whether it is NT, Windows 2000, MacOS, Linux, or what). The operating system is the only software I have so far.
a. What software do I need to obtain for it in order to be able run Java applications that other people have written?
Ans:
A Java Virtual Machine.
b. ok, I followed your advice for (a). Now what additional software do I need to obtain for it to be able to run Java applets that other people have written?
Ans:
Any Java compatible browser or
an appletviewer.
c. ok, I followed your advice for (b) as well. I also obtained an editor, so now I can type in and edit files too. Now what additional software do I need to be able to program my own applets?
Ans:
A Java compiler. This is found, for example, in JDK (Java Development Kit) and other
other Java development environments like Microsoft VJ++ or Code Warrior,
which include editor, java compiler, appletviewer, and other programming aids.
6. [5 pts]
a. What exactly does a browser do with an html file? (Tell me what "html" stands for as part of your answer.)
Ans:
A browser interprets the HTML(HyperText
Markup Language) file and displays it based on the tags present in it.
b. What does a browser use http for? (Tell me what "http" stands for as part of your answer.)
Ans:
A browser uses HTTP(HyperText Transfer
Protocol) for receiving files from the webservers on the internet.
c. What information does a browser get from a url? (Tell me what "url" stands for as part of your answer.)
Ans:
A URL(Uniform Resource Locator)
provides the browser with the information necessary to locate
a file on the internet.
7. [5 pts] Do exercise 5, p. 53.
Ans:
15,46,70,106,160,80,40,20,10,16,8,4,2,4,2,4,2...
6,10,16,8,4,2,4,2,4,2,4,2...
8. [5 pts] Do exercise 18, p. 54, using pseudocode. Another way of expressing this problem is that you are to define Square objects that are able to tell you (take the responsibilities for computing) their areas and their circumferences.
Ans:
public class Square
private double
side
public Square(double
s)
side = s
public double
calculateArea()
return side*side
public double
calculatePerimeter()
return 4*side
public void setSide(double
s)
side = s