FinalExam Previous
FinalExam Previous
FinalExam Previous
Student Name :
Student ID:
Section No.:
Instructions:
Page 1 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
Student Name (in English): __________________________________________ Student ID: _____________________________
Choose one correct answer for each statement and fill the table below.
Question 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Answer
3- The number of times the word “loop” will be printed in the following code is:
for (int i = 0; i< = 10; i--)
System.out.println(“loop”);
a) 0
b) 10
c) 11
d) Infinite
Page 2 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
Student Name (in English): __________________________________________ Student ID: _____________________________
Page 3 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
Student Name (in English): __________________________________________ Student ID: _____________________________
a) CBA
b) ABC
c) BCD
d) DCB
14- The output of the following code
int x=2;
double y=9;
System.out.print(y/x);
a) 4
b) 4.5
c) 5
d) Compile Error
Page 4 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
Student Name (in English): __________________________________________ Student ID: _____________________________
1- Consider the following headers, how would you call these methods in your class’s main method. [2 marks]
2- Consider the two methods below and write their headers without their body codes. [2 marks]
3- Consider the methods below and write their headers and body codes as described. [5 marks]
Page 5 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
Student Name (in English): __________________________________________ Student ID: _____________________________
4- The following code is implemented using for-loop, convert this code to be a recursion method called
GetSum [ 3 marks]
5- Convert the following formula method to accept any number of int arguments. [ 3 marks]
Page 6 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
Student Name (in English): __________________________________________ Student ID: _____________________________
Question 111: Write a java class To be answered in (35) Minutes [ ] / _10_ Marks
Write a java class called Products that reads product information and extracts products information
and print it to the user. The product code consists of the country initials, the product code followed by
the product serial number, product code example: UK-001-176
Your class should contain One Method plus the main method.
ExtractInfo that receives a product code as a String. The method should extract the origin country
of the product, its code and then the product serial number and prints out the result and then saves the
same result into a file called “Info.txt” as shown below
Page 7 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
The end of final exam, good luck!
Page 8 of 9
Imam University | CCIS | Doc. No. 006-01-20141026
Java String Methods
http://introcs.cs.princeton.edu/java/11cheatsheet/
Page 9 of 9
Imam University | CCIS | Doc. No. 006-01-20141026