COURSE CODE: COM 328
COURSE TITLE: OBJECT ORIENTED PROGRAMMING II
REVIEW QUESTIONS
a) A message must contain the number to call, the number of the sender, and the message
text.
Define a class Message, with:
i) A method that creates an instance starting from an object of the class
MessageText and two strings that represent the number to call and the number
of the sender. [2 Marks]
ii) A method that takes as parameter a phone number, and uses it to update the
number to call of the message. [3 Marks]
iii) A method that prints the message. [2 Marks]
b) A positive integer is said to be prime if it is divisible only by 1 and by itself. Write a
method that takes as parameter a positive integer, and returns a boolean that indicates
whether the integer is prime or not. [5 Marks]
c) All methods in Java are dynamic polymorphic as a design choice. Discuss the
advantages and disadvantages of making dynamic polymorphism optional for Java
methods. [6 Marks]
d) In the try … catch … finally block, explain the type of code expected in each block. Use
their syntax to show the answer. [6 Marks]
e) Explain what is Exception propagation? Illustrate your answer with Java code snippet
using throw new ArgumentException(“Illegal input to the method.”).
[5 Marks]
f) Define a class Person with the private data members: first name, last name, and date of
birth; public methods: get name and get date of birth and a constructor to initialize the
data members. [5 Marks]
g) Define another class Student that inherits from class Person and has the following
properties: student registration number, address, and programmme and the public
methods: get grade and a constructor to initialize student address and programme.
Ensure that the Person constructor is called in the Student constructor.
[6 Marks]
h) Using a scenario of choice (Such as Course Registration) Write a program that
demonstrates inheritance, method Overriding and Overloading and polymorphism.
Make sure to comment your program appropriately. [10 Marks]