Southern College
Kolej Selatan
南方学院
Final Examination
Semester 3 / Year 2007
COURSE : INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
COURSE CODE : CCIS1103
TIME : 2 1/2 HOURS
DEPARTMENT : COMPUTER SCIENCE
CLASS : CIC07-B, CIC07-A
LECTURER : NG MEE MEE
Student’s ID :
Batch No. :
Notes to candidates:
1. The question paper consists of 6 pages.
• Section A: 10 questions ( 10 marks)
• Section B: 10 questions ( 15 marks)
• Section C: 5 questions ( 30 marks)
• Section D: 4 questions ( 45 marks)
2. Answer all questions.
3. Return the question paper with your answer booklet.
SECTION A: TRUE OR FALSE QUESTIONS ( 1 0 X 1.0 = 10 MARKS)
Indicate the statement or sentence is true or false.
A1. A stream of bytes from which data are read is called an input stream.
A2. Java lets you read characters from a file one character at a time, one word at a time, or one
line at a time.
A3. The first generation of programming language is assembly language.
A4. An integer is a positive or negative whole number.
A5. The logical operator OR is indicated by !.
A6. A(n) array is collection of similar items or elements that are ordered by position.
A7. A text file is a file that contains nothing but characters.
A8. m++, m=m+1, an m+=1 are all equivalent expressions.
A9. The assignment operator (=) and equal to operator (= =) can be used interchangeably.
A10.Colons (: ) mark the end of each statement in a Java program.
SECTION B: MULTIPLE CHOICE QUESTIONS ( 10 X 1.5 = 15 MARKS)
Identify the letter of choice that best completes the statement or answer the question.
B1.
B2.
B3.
What does HTML stand for?
1. hypertext media language
2. hypermedia text language
3. hypertext markup language
4. hypertext markup list
Consider the following code segment
int[] hit = new hit[5];
hit[0] =3;
hit[1] =5;
hit[2] =2;
hit[3] =6;
hit[4] =1;
Sytem.out.println(hit[1+3]);
What is the output of the code segment above?
1. 1
2. 3
3. 5
4. 6
What are the two types of file access Java supports?
1. Serial, random
2. Random, sequential
3. Linear, sequential
4. Sequential, serial
B 4.
Which of the following is the Java symbol for logical AND?
1. &&
2. !
3. = =
4. ||
B5.
What type of expression returns either true or false?
1. Boolean
2. Arithmetic
3. Initialization
4. None of the above
B 6.
How many time will the following loop execute?
int counter =2;
while(counter <10){
counter +=2;
}
1. 3
2. 4
3. 5
4. 0
B7.
Small java programs download from web pages are called:
1. Threads
2. GUI’s
3. Servlets
4. applets
B8.
The java compiler will ignore everything after what symbol?
1. +
2. =
3. //
4. new
B9.
The expression 3+2*5-1 yields:
1. 24
2. 12
3. 11
4. 20
B
10.
How do you find the length of an array called employees?
1. employees.length()
2. employees.size()
3. employees.size
4. employees.length
SECTION C: SHORT QUESTIONS (30 MARKS)
C1. Assume that the array a contains the five integer 34, 23, 67, 89 and 12. Write the values of
the following expressions: (3 x 2.5 = 7.5 marks)
1. a[1]
2. a[a.length-1]
3. a[2] + a[3]
C2. Declare and instantiate array variables for the following data: (2 x 2.5 = 5 marks)
1. An array of 15 doubles
2. An array of 20 integers
C3. Assume that x has the value 3.2 and y has the value 4. State the value of the variable z after
the following statements: (2 x 2.5 = 5 marks)
1. z = Math.round(x);
2. z = Math.pow(y,3);
C4. Assume that x is of type of double and y is of type of int. Also assume that x is 4.5 and y is
2. Write the values of the following expressions: ( 2 x 2.5 = 5 marks)
1. (int) x*y
2. (int)(x*y)
C5. State the type of error that occurs in each of the following pieces of code. ( 3 x 2.5 = 7.5
marks)
1. x = y/0
2. x + y=z
3. area = length + width
SECTION D: LONG QUESTIONS (45 MARKS)
D1. Write a for loop that will print out all the multiplies of 3 from3 to 36, that is: 3 6 9 12 15 18
21 24 27 30 33 36. (5 marks)
D2. a. Convert the following for loop into a do-while loop.( 5 marks)
b. Convert the following for loop into a while loop.( 5 marks)
int sum = 0;
for (int i = 0; i < 100; i++) {
sum += i;
}
D3. MyJava Coffee Outlet decided to give discount to volume buyers. The discount is based on
the following table: (15 marks)
Order Volume
Discount
>=25 bags
>=50 bags
>=100 bags
5% of total price
10% of total price
15% of total price
Each bag of beans costs RM5.50. Write an application that accepts the number of bags ordered
and prints out the total cost of the order in the following style, using Scanner object.
Sample output of the program:
D4. Write java program that allow the user to enter an array of 10 examination scores from
mathematics test, compute the class average, and display all the scores and the class average to
the screen. (15 marks)
Sample output of the program:
000
© Copyright 2026 Paperzz