



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CS 110 : I NTRODUCTION TO C OMPUTER S CIENCE Student’s Name: TEST 1: S EPTEMBER 27, 2006
M AXIMUM MARK : 100 Time allowed: 50 minutes
Unless otherwise stated, the questions are with reference to the JAVA Programming Language. You may use extra sheets if need be.
Q1: Concepts and Definitions (30 marks)
1a. What is the difference between an algorithm and a program?
1b. In one sentence each, describe the meaning of each of the following terms:
Class
Object
Method
Inheritance
Superclass
Subclass
JVM (explain what it is used for)
1c. For each of the following devices, indicate whether it provides temporary, or permanent storage
Floppy disk ---------------
Zip Disk ---------------
CD-ROM ---------------
Hard disk ----------------
1d. List any five of the various steps in software development.
1e. List three reasons why you may use the formal software development methodology in program development
1f. Very briefly, describe the three types of errors you may encounter in a JAVA program (Here, you are required to list the types of error, and state in one or two sentences , what each means).
4c. Determine whether each of the following is a valid Java statement. Assume the identifiers x, y, and z are integers. A. int a; B. x + y = z; C. const int b : 5; D. a = b % c;
4d. Assume int x ; For each of the following statements, determine the value of x.
A. x = 10.0 / 4.0 + 2 * 3; B. x = 10 % 4 + 13 % 3; C. x = 10 / 4 + 13 / 3; D. x = 15 % 6 * 4; E. x = 15 % (6 + 3);
4e. List the results that will be produced if the following is executed: (Ignore any syntax error)
public static class SampleProgram
public static void main(String [] args) { int m, n; int average;
m=5; n=2;
System.out.print (“The average is: ” ); average = (m+n)/2 ;
System.out.print (“ “ + average); System.out.println (“”); System.out.println (“Bye”);
}
Q5: Writing a Program (15 marks) Write a program to display the area of certain segment of a quadrant. The area of the segment from a quadrant of circle is given by:
Area = −
π
where R is the radius of the circle, and π = 3. 142 is a constant. The program should accept the height and base from the user, and display the calculated area.
You may use a function if you wish. However, you are NOT required to use functions in your program.