EXAMSHARE

Western Delta University, Oghara Delta State

department of computer science
college of computing
western delta university

first semester examination 2022/2023 session

CSC201 - computer programming I (Java) time: 2hrs: 30mins

answer question 1 and any other THREE questions


  1. Question 1 (Compulsory)

    1. State two reasons why we learn both structured programming and object-oriented programming. (4 marks)
    2. State two major application areas of Java programming language. (2 marks)
    3. State two major features of Unified Modeling Language (UML). (4 marks)
    4. 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)
    5. Highlight the four vital components of a for loop. (4 marks)
    6. A person invests N100,000:00 in a savings account yielding 5% 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 10 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)
  2. Question 2

    1. Define the following terms as used in Java development environment.
      1. Javac.exe
      2. Java.exe
      (4 marks)
    2. Why is the Java programming language platform independent? Illustrate with a diagram. (4 marks)
    3. What is a loop? (2 marks)
    4. Write a Java application that computes the sum of square of odd numbers between 1 and 50. (5 marks)
  3. Question 3

    1. Define the following:
      1. Local variable
      2. Instance variable.
      (4 marks)
    2. What is a static method? Illustrate with one example. (4 marks)
    3. Write a method that converts a Fahrenheit temperature to Celsius temperature using the expression: Celsius = (Fahrenheit - 32) * 0.55 (4 marks)
    4. Give the syntax of the while loop. (3 marks)
  4. Question 4

    1. Define enhanced for loop. (2 marks)
    2. State one situation in which the use of the enhanced is valuable.(2 marks)
    3. Highlight three methods available in the predefined class called Arrays. (3 marks)
    4. Write a java program segment to illustrate each of the methods stated in (4c) (6 marks)
    5. State two differences between primitive type and reference type.(2 marks)
  5. Question 5

    1. Define the following as used in Java file processing:
      1. Stream
      2. Text file
      3. Sequential file.
      (6 marks)
    2. 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)
    3. Highlight two differences between a primitive variable and non-primitive variable. (2 marks)
  6. Question 6

    1. Define an ArrayList. llustrate with an example. (4 marks)
    2. Define a static method. Illustrate with one example. (4 marks)
    3. 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 a Java program that initializes the scores, computes the total and average scores. (7 marks)