department of computer science
college of computing
western delta university
first semester examination 2023/2024 session
CSC201 - computer programming I (Java) time: 2hrs: 30mins
answer question 1 and any other three (3) questions
Question 1 (Compulsory)
- State two reasons why we learn both structured programming and object-oriented programming. (4 marks)
 - State two major application areas of Java programming language. (2 marks)
 - State two major features of Unified Modeling Language (UML). (4 marks)
 - The entity television can be regarded as a class with attributes and behaviours. Derive the attributes and behaviour of the class television using UML class diagram. (5 marks)
 - Highlight the four vital components of a for loop. (4 marks)
 - A person invests a certain of money in a savings account at a given interest. Assuming that all the interest is left on deposit, calculate and display the amount of money in the account at the end of each year for n years. Write a Java application to determine the amounts using the formula:
A = P(1+R)n
where
P is the original amount invested (i.e., the principal)
R is the annual interest rate
n is the number of years
A is the amount on deposit at the end of the nth year. (6 marks) 
Question 2
- Define the following terms as used in Java development environment.
- Javac.exe
 - Java.exe
 
 - Why is the Java programming language platform independent? Illustrate with a diagram. (4 marks)
 - What is a loop? (2 marks)
 - Write a Java application that computes the sum of square of even numbers between 2 and 50. (5 marks)
 
- Define the following terms as used in Java development environment.
 Question 3
- Define the following:
- Local variable
 - Instance variable.
 
 - What is a static method? Illustrate with one example. (4 marks)
 - Write a method that converts a Fahrenheit temperature to Celsius temperature using the expression: 
Celsius = (Fahrenheit - 32) * 0.55(4 marks) - Give the syntax of the 
whileloop. (3 marks) 
- Define the following:
 Question 4
- Define enhanced for loop. (2 marks)
 - State one situation in which the use of the enhanced is valuable.(2 marks)
 - Highlight three methods available in the predefined class called Arrays. (3 marks)
 - Write a java program segment to illustrate each of the methods stated in (4c) (6 marks)
 
Question 5
- Define the following as used in Java file processing:
- Stream
 - Text file
 - Sequential file.
 
 - Write a Java program that requests from the user matriculation number, total points earned, total units registered and compute the GPA using the expression: 
GPA = Total Points Earned / Total Units Registered. Write your output consisting of Matriculation No., Total Units, Total Points, and GPA to a file named honour.txt. (7 marks) - Highlight two differences between a primitive variable and non-primitive variable. (2 marks)
 
- Define the following as used in Java file processing:
 Question 6
- Define an ArrayList. llustrate with an example. (4 marks)
 - Define a static method. Illustrate with one example. (4 marks)
 - The scores of ten students in a given examination are represented in a one-dimensional array as follows: 57 40 34 61 66 56 48 56 52 51. Write methods to accomplish the following:
- Compute the largest score (3.5 marks)
 - Compute the smallest score (3.5 marks)