CS 110 Fundamentals of Computing -
Sample Hour Exam 1
Professors Bolker and Rodriguez
Closed book and notes
Here are a few sample questions. Some of the questions on the exam
will be just like these. Some will be different. But if you can answer
all of these you can probably answer them all.
You will be given a listing for program NewShape.java, which
draws some particular shape on a Screen. Some of the
questions refer to that program.
-
In this fragment of
NewShape.java
(with line numbers)
39
40
41
-
What are the tokens?
-
Which of those tokens are identifiers?
-
Which of those tokens are Java keywords?
-
Which represent variables? What are the types of these variables?
-
Find all the places in these lines where a message is sent to an
object. In each case identify the name and type of the object
receiving the message. Where would you expect to find the code for the
method that will respond to the message? Write the declaration for
that method.
-
Use the space below (ruled so that character positions
are easy to identify)
to show the
exact, complete output from the command
%> java NewShape
------------------------------
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
-
What does
this
do on line xx of
NewShape.java
?
-
What does
void
mean on line xx of
NewShape.java
?
-
Describe (two) coding conventions for Java programs and show how the
author of the NewShape class used those conventions.
-
Draw a box-and-arrow picture of the NewShape object referred to by
variable
whatever
declared and initialized on line xx of
NewShape.java
Be sure to show the fields of that object.
Use the other side of this paper.
-
Can two methods in the same class have the same name? Can two methods
in different classes have the same name? If the answer to either
question is "yes", tell how Java knows which one to use when a client
sends a message with that name.
-
A for loop question.
-
A question about using xemacs. (You should be able to answer this one
even if you are using some other development environment at home.)