ENGR 135 Take Home Midterm (3/20/02)
README
- You HAVE to print out all the answers as well as the output and source listings
of the programming assignments. Please hand in both the printouts and a diskette
containing your programs. The exam is collected in class on 4/6/02. If you
are late in any way, 50% will be taken off in the first day, then 100% in
the second day and after.
- If the instructor cannot show up on 4/6/02, the exam will be collected in
the next lecture. This will only happen under extreme situation.
- DO NOT talk about the exam, COMPARE the exam, DISCUSS the
exam, WORK WITH OTHER PEOPLE on the exam and CHEATING in
any way you could think of. If two answers are found to
be the same due to cheating. A F will be given for the
course as a result and a letter might be sent to Dean of
Students and the Computer Science Department. I do not
want to do any of that, so LEARN the materials and DO IT
YOURSELF.
MID TERM QUESTIONS
- The exam will total to 200 points.
- If you think the questions are not stated clearly in any
way, WRITE down your assumptions and ask the questions.
No email answer can be obtained from the instructor
individually in order to be fair with all the students.
- Good Luck and have fun.
QUESTION 1
a. How many types of comments are in Java? What are they? (5 points)
b. Why use double instead of float in Java programming? (5 points)
c. Do all Java application have function(s)? (5 points)
d. What is the best way to find out the length of an array? (5 points)
QUESTION 2
a. What is the difference between Class and Object? (5 points)
b. Do you have to import a package for every Java program? Explain? (5
points)
c. Do you always need to create your own constructor for a class? (5
points)
QUESTION 3
a. There are only three access modifiers (public, private and protected)
in Java. Right? (5 points)
b. Which class has more data and methods in general: superclass or
subclass? (5 points)
c. What is protected keyword means in Java? (5 points)
QUESTION 4
a. Where is the applet runs on? (5 points)
b. How do you identify a program running on a computer in a network?
(5 points)
c. If you are using Java code that throws exceptions, what do you do? (5
points)
QUESTION 5
a. Can you directly read from an URL object? (5 points)
b. What is a Socket? (5 points)
c. When creating a ServerSocket, why you do not need to provide a
hostname? (5 points)
QUESTION 6
(i1). Develop an object model, including
classes and attributes of the following "copy machine" problem. You
can make reasonable assumptions. (20 points)
- The machine copies A4 size paper only.
- If the original is too big, the machine will
indicate a warning of size mismatch.
- The machine can do either black & white or
color copy.
- The price for black & white is 25 cents and
color is $1.
- Users can select how many copies to be done.
- Users have to input money first before any copy
can be done.
- The machine accepts only quarters. Other coins
are immediately returned.
- An error message will be displayed if the money
inputted is not enough.
- Quarters exceeding the cost of copying are also
returned when the copy button is pressed.
- The vending machine has two buttons, a black
& white copy button and a color copy button.
- (This is the same as the in-class exercise, so
you should remember what it kind of looks like. However, you should redo
the object model one more time as an individual to make sure that you are
able to implement it by yourself.
Also, remember that you have to do the whole midterm including this
problem by yourself.)
(i2a). Use any programming language
(Java, C++, C) to implement the object model in part 1. If the object model
does not include a client or user, implement a client that uses a text menu
to operate the copy machine. For example:
Copy Machine Menu:
- Deposit money
- Press Black/White button
- Press Color button
- etc …
I will use the above
menu to grade this part of the question. (90 points)
(i2b). Write down 5 detail test cases
on how to test your implementation in i3a. (10 points)
Answer: