Professional Documents
Culture Documents
OBJECT_ORIENTED_PROGRAMMING_
OBJECT_ORIENTED_PROGRAMMING_
PROGRAMME(S):
SESSION:DAY/EVENING
MODULE CODE AND TITLE: LEVEL:
2108,2101 OBJECT ORIENTED DIT, BIT, BCS, BSF
PROGRAMMING WITH JAVA
DATE: TIME:
June, 2024
DURATION: TOTALMARKS:
6 Hours 100
EXAMINER/LECTURER: MODERATOR:
Mr. Bazigu Alex Dr. David Kakeeto
A month is a leap month if it is divisible by 4 but not by 100 or if it is divisible by 400 based
on the Boolean expressions below.
a) Create a Java class called “leapmonth”, declare the variable the program.
b) Write a Java program to check whether a given month is a leap month
c) Save the project in the folder created on desktop, screenshot all your program codes
and output and upload the code to GitHub Repository called Question1-leapmonth.
d) Attach the screenshot of your final output on the answer sheet and the link for your
repository
The demand for students in institutions has finally forced Balex institute to structure their
online courses for anyone in Africa and beyond to enroll for them. The following are the details
per course as shown in the table below:
(a) Using Java IDE, create an application called "balex" and create a Java class called
"courses".
(b) Identify and declare the variables in a program.
(c) Develop a Java application that prompts the applicant to feed in the CourselD, and the
details of the course are returned to the screen. When the wrong code is fed into the
system, "Wrong CourselD details" should be returned.
(d) Save the project in the folder created on desktop, screenshot all your program codes
and output and upload the code to GitHub Repository called Question2-balex.
(e) Attach the screenshot of your final output on the answer sheet and the link for your
repository.
Access Modifier
Defining class
Class in same package
Subclass in different package
Non-subclass in different package
(c) A Java game designer wishes to store all the game preferences (e.g., player name, screen
size, music volume, etc.) within a custom Preference class.
i) Assuming each preference is stored as a unique String key mapping to a String
value, give a simple implementation of Preference that allows for efficiently setting
or updating preferences and retrieving previously set ones. Your implementation
should define an exception that is thrown when a preference key is requested but
not present.
ii) It is important that only one Preference object exists in a running game. Show how
to apply access modifiers and the Singleton design pattern to ensure this. Your
implementation should lazily instantiate the object. Is it necessary to make your
class final or Cloneable? Explain your answer.
You have been asked by a mathematics student to develop a Java program for him to practice
subtraction. The program randomly generates two single-digit integers, numberl and number2,
with numberl > = number2 and displays to the student a question such as "What is 9 - 2?".
After the student enters the answer, the program displays a message indicating whether it is
correct.
Required.
a) Bukoto Village Bank Limited would like to create a system which inputs each of the
members principal amounts of money deposited on their accounts for investment at an
interest rate determined by the management for a certain period of time. The system
calculates the value of investment after the time frame elapses. Write Java Code statements
to implement the above program using each of the following selection statements.
(i) For Loop
(ii) While Loop
b) Alexa and Balexis Merchants was contracted by L&M Limited to develop a Java
Program that prompts a user to enter any three numbers. The program then displays the
product, sum and the maximum of the numbers that the user entered in a tabular format as
illustrated below.
48 18 8
(a) You are given the following implementation for an element of a list
(c) Another developer changes your implementation to a generic class FuncList<T> that can
hold values of any type T.
(i) This means that FuncList<T> is no longer immutable. Explain why and what
could be done to remedy this.
(ii) Java prohibits covariance of generic types. Is this restriction necessary in this
case? Explain why with an example.