login name ________________________ real name_________________________ 1 2 3 4 5 6 7 total /50 /20 /20 /15 /15 /15 /30 /165
Note that some of the answers go on this exam, some in your blue book. If you need more space continue in the blue book.
WcCommand.java
(attached, with
line numbers). That code compiles and
runs correctly (We have tested it).
Here is a fragment of a Juno session using wc
:
notMars> ls 3 files: greeting root 12 Tue Dec 18 13:06:35 EST 2001 greeting2 root 13 Tue Dec 18 13:06:35 EST 2001 users/ root 5 Tue Dec 18 13:06:35 EST 2001 notMars> cat greeting hello, world notMars> cat greeting2 hello, world notMars> wc greeting *** notMars> wc greeting2 *** notMars> wc foo *** notMars> wc users *** notMars> wc *** notMars> help shell commands cat: display contents of a TextFile cd: change current directory help: display ShellCommands logout: log out, shut down the Shell ls: list contents of current directory mkdir: create a subdirectory of the current directory newfile: create a new TextFile wc: *** notMars>
greeting
but
a 13 for greeting2
.
WcCommand.java
.
***
in the script
above, show what Juno's response would be. Your answer should take
into account your answer to the previous question.
WcCommand.java
:
int words = new StringTokenizer(contents).countTokens();
countTokens
declared? Write the declaration header, and a javadoc
comment to accompany it.
retrieveJFile
in Directory.java
is
executing because it was
called from line 39 in WcCommand.java
?
Your answer (in the blue book)
should list the methods and the classes they are in:
Here's a framework:
Class method Juno main // you fill in the rest Directory retrieveJFile
commandTable
declared on line 36 of
Juno.java
(Program Listing 7.11) after line
line 79 in method fillTable
in
ShellCommandTable.java
has executed.
Here's how your diagram should start
Discuss (in the blue book) each of these constructions, referring to explicit examples from programs you have worked on this semester. We should be able to understand your answer without having the code in front of us.
public boolean myMethod() { if (allIsWell) { // do the job return true; } return false; }
public void myMethod() throws ABadThingHappenedException() { if (!allIsWell) throw new ABadThingBadHappenedException(); // do the job }