EXAMSHARE

Western Delta University, Oghara Delta State

department of computer science
college of computing
western delta university

first semester examination 2023/2024 session

CSC309 - advanced computer programming (Java) time: 2hrs: 30mins

Answer four (4) questions


  1. Question 1 (Compulsory)

    1. Define the following:
      1. Event
      2. Action Listener
      (4 marks)
    2. Wtite a Java program segment that selects an item from a comboBox and assign the selected item to a textField. (4 marks)
    3. Write a Java method to convert the expression: Celsius = (Fahrenheit - 32) * 0.55. (4 marks)
    4. The Malthusian population model for estimating the population of a country is given as: Pt = P0t0eR(t-t0).
      where:
      Pt is the estimated population at time t,
      Po is the initial population at time t0,
      R is the population growth rate,
      to is the initial time in year,
      t is the final time in year in which population is to be estimated
      1. Manually design a form to obtain the necessary input values from the user (4 marks)
      2. Create a command button with a label Estimate Population in the form. Write Java code for the Estimate Population button so that when clicked, computes the estimated population using the given expression. (9 marks)
  2. Question 2

    1. Define Inheritance as used in Object Oriented Programming. (2 marks)
    2. Illustrate with one example how a class can inherit the methods available in another class. (5 marks)
    3. Define the following:
      1. Exception
      2. Error
      (4 marks)
    4. Write a Java program that generates ArrayIndexOutBoundException when there is an attempt by the user to access an array beyond the maximum index.(4 marks)
  3. Question 3

    1. State four Java IO.File class methods that can be used to manipulate files. (4 marks)
    2. State the role of the method named in (3a). (4 marks)
    3. Assuming the user is prompted to enter a name that is either file or directory. Write a Java program that determines if the name exists and invoke a method called analyzeFile that gives the properties of the file if the name is a file. (5 marks)
    4. Highlight two major benefits of writing Java applications as unit of classes. (2 marks)
  4. Question 4

    1. Define the following as used in Java Class definition:
      1. Getter
      2. Setter
      (3 marks)
    2. State two differences betweeen a constructor and a method. (3 marks)
    3. Give a class definition of the computation of area of a box using UML class diagram and with the associated Java code. (5 marks)
    4. Define the keyword Super as used in object-oriented programming. Support your answer with the appropriate Java application. (5 marks)
  5. Question 5

    1. State the function of the following jTextField methods: setText and getText. Write a Java program segment to illustrate their use. (6 marks)
    2. Why is the private modifier used in the declaration of variables. (2 marks)
    3. Manually design a form that retrieves the following items of data from the user: MatNo, Surname, FirstName, Department, and GPA. Write a Java program to transfer the entered data by the user to a database table when a command button called "Transfer Data" is clicked. (7 marks)
  6. Question 6

    1. Define the method actionPerformed.(2 marks)
    2. What is a JLabel? (2 marks)
    3. State two differences Radio button and CheckBox GUI components. (4 marks)
    4. Given that X and Y are square matrices, i.e.,
      X =
      [
      984
      537
      625
      ]
      Y =
      [
      263
      731
      468
      ]
      Design a Java class called MatMult that computes the product of X and Y. Write your output to a formatted file called matxy.txt. (7 marks)