CS151 Take Home Midterm (3/8/01)
- 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 3/13/01. If you are late in any way, 50% will be
taken off in the first day, then 100% in the second day
- If the instructor cannot show up on 3/13/01, 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
MID TERM QUESTIONS
- The exam will total to 150 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.
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)
a. What is the difference between Class and Object? (10 points)
b. Do you have to import a package for every Java program? Explain? (5
c. Do you always need to create your own constructor for a class? (5
a. There are only three access modifiers (public, private and protected)
in Java. Right? (10 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)
a. Where is the applet runs on? (5 points)
b. How do you identify a program running on a computer in a network? (10
c. If you are using Java code that throws exceptions, what do you do? (5
a. Can you directly read from an URL object? (5 points)
b. What is a Socket? (10 points)
c. When creating a ServerSocket, why you do not need to provide a
hostname? (5 points)
QUESTION 6 - Java Programming (50 points)
Write a Java application called URLMidterm that will
- Present an UI (with swing) to the user and request
- Create an URL object with http as protocol and the inputted address as
- Parse the newly created URL object and print out in an output UI component
such as text area in swing
- port and
- Then, read directly from the URL object and print out all the contents
from the input stream to the output file specified in step 1.
- Run the program by "java URLMidterm"