0% found this document useful (0 votes)
8 views3 pages

Csc3303-Itc33 QP 2020 2021

The document outlines the examination structure for a computer science course at Yusuf Maitama Sule University, detailing the questions related to object-oriented programming in Java. It includes tasks such as defining an Employee class, implementing interfaces, handling exceptions, and understanding Java concepts like access modifiers and constructors. The exam consists of multiple questions with specific requirements for coding and theoretical explanations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Csc3303-Itc33 QP 2020 2021

The document outlines the examination structure for a computer science course at Yusuf Maitama Sule University, detailing the questions related to object-oriented programming in Java. It includes tasks such as defining an Employee class, implementing interfaces, handling exceptions, and understanding Java concepts like access modifiers and constructors. The exam consists of multiple questions with specific requirements for coding and theoretical explanations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

YUSUF MAITAMA SULE UNIVERSITY, KANO

FACULTY OF SCIENCE
DEPARTMENT OF COMPUTER SCIENCE
2020/2021 FIRST SEMESTER EXAMINATIONS – MARCH 2021
CSC3303 – Object-Oriented Programing/ITC3309 – java
workshop
Attempt Question 1 and any other 3 Questions Time Allowed: 3 hours
1. [25 marks]
a. [14 marks] Define a class called Employee with the following [9 marks]:
i. [1 mark] Data fields: emp_id, salary, name, address, department, email.
ii. [3 marks] Shared fields called requiredHours and employeeBonus and
initialize them to values to be entered by the user in a static initializer.
iii. [1 mark] A no-argument constructor that initializes name to “Sabon Maaikaci”,
emp_id to “000” and salary to 200000.0.
iv. [1 mark] a parameterized constructor for initializing emp_id, name and salary.
v. [1.5 marks] Another parameterized constructor for initializing all the data
members. (Note: use of constructor call is mandatory).
vi. [1 mark] A setter and a getter for emp_id.
vii. [1 mark] A setter and a getter for name.
viii. [2 marks] computeOvertime(int hoursWorked) that computes overtime
payment and add it on top of salary. The overtime payment is 5000.0 per hour.
ix. [1 mark] computeEmployeeBonus() that computes bonus base on
employeeBonus (a percentage) and add it on top of salary.
x. [1.5 marks] printEmployeeDetails() method that prints String representation of
an object of Employee class. The printed String should contain the following
each on a separate line:
Employee Name: (name)
Employee Id: (emp_id)
Employee Salary: (salary)
Employee Address: (address)
Employee Department: (department)
Employee Email: (email)
b. [2 marks] Write a program to test Employee class.
c. [1 mark] Create an interface called SpecialEmployeeInterface with
specialAllowance method.
d. [3 marks] Create a subclass of Employee class called SpecialEmployeeClass that
implements SpecialEmployeeInterface interface. specialAllowance method
computes allowance based on salary as follows:
• 12% of salary: for salary between 200,000 and 300,000 inclusive
• 10% of salary: for salary above 300,000 but less than 500,000.

Page 1 of 3
• 8% of salary: for salary above 500,000 inclusive.
e. [5 marks] Write a Java program that declares a jagged array of 5 Employee objects
arrays, containing 1, 2, 3, 4, 5 objects respectively, read all the required details from
the user, compute bonus for each object, and hence use the printEmployeeDetails()
method in (a-viii above) to print the details of each of the objects.
2. [15 Marks]
a. [3 marks] In Java, methods can have variable length argument lists. Explain the
format and rules governing the implementation of these kind of methods and hence
provide a suitable example depicting its codification and usage.
b. [6 marks] When an error that cannot be automatically resolved in Java occurs, an
object of the respective class of the error is created and thrown. This object is called
an exception. If not properly handled, it will simply hinder the program execution.
Clearly explain what an Exception is; its types; methods associated with its objects;
how it can be handled; and finally provide a programming example of how an
exception can be handled using try and catch.
c. [2 mark] Differentiate between Variable and Reference Variable.
d. [4 marks] In Java, it is possible to prevent any class from being instantiated through
the use of some approaches. What are these approaches? Cite an example in each
case.
3. [15 Marks]
a. [4 marks] Distinguish between the following:
i. Setters and Getters
ii. extends and implements keywords
iii. initializers and static initializers
iv. throw and throws keywords
b. [3 marks] Theoretically and technically depict the relationship between
Constructors and the following:
i. Classes
ii. Objects
iii. Inheritance
c. [4 marks](reverse identical arrays) Two arrays array1 and array2 are reverse
identical if they have the same length and the first element of array1 is equals to the
last element of array2, the 2nd element of array1 is equals to the 2nd to the last
element of array2 and so on. The following 2 arrays are reverse identical:
array1 = {1,2,3}
array2 = {3,2,1}
Write a method that returns true if array1 and array2 are reverse identical, using the
following header
public static Boolean isReverseIdentical (int[] array1, int[] array2)
d. [4 marks] Explain the various Access Modifiers of Java.
4. [15 Marks]
a. [6 marks]

Page 2 of 3
i. [3 marks] Define a method that takes in a positive integer say n, as
parameter, check and determine if the number is prime or not.
public static boolean isPrime(int n)
ii. [3 marks] Write a Java program that reads in a prime number greater than
10, compute and display the sum and average of all the positive integers less
than the prime number. (Hint: use the isPrime method above).
b. [4 marks] Define the following terms:
i. Final field
ii. Setters and Getters
iii. Instance member
iv. Static member
c. [3 marks] Theoretically and technically (in codes) discuss the ideas behind
initializers. In addition to this, cite an example on how an initializer can be replaced
by a method call or a constructor.
d. [2 marks] briefly explain the features object-oriented programming languages
share with non-object-oriented ones.
5. [15 marks]
a. [2 marks] A Java class cannot be declared as both abstract and final. Discuss.
b. [6 marks] Distinguish between the following:
i. Method Overloading and Method Overriding
ii. Class-based or Prototype-based
iii. Abstract Class and Interface
iv. Default Constructor and Parameterized Constructor
c. [6 marks] with the exception of class and object, discuss any other four (4) of the
concepts of OOP.
d. [1 mark] Write a Java program of your choice.

Page 3 of 3

You might also like