ENGR 135 Take Home Midterm (3/20/02)

README

 

MID TERM QUESTIONS

 

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)

(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:

  1. Deposit money
  2. Press Black/White button
  3. Press Color button
  4. 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: