0% found this document useful (0 votes)
54 views1 page

Com 328 Review Questions

The document outlines 8 review questions for an Object Oriented Programming II course. The questions cover: 1) Defining a Message class with methods to create instances, update phone numbers, and print messages. 2) Writing a method to check if an integer is prime. 3) Discussing advantages and disadvantages of optional dynamic polymorphism in Java methods. 4) Explaining the expected code in try, catch, and finally blocks using syntax. 5) Explaining exception propagation with a code example. 6) Defining a Person class with private data and public methods. 7) Defining a Student class that inherits from Person with additional properties and ensuring the parent constructor is called. 8) Writing a program demonstrating inheritance, overriding, over

Uploaded by

Njeru Daniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views1 page

Com 328 Review Questions

The document outlines 8 review questions for an Object Oriented Programming II course. The questions cover: 1) Defining a Message class with methods to create instances, update phone numbers, and print messages. 2) Writing a method to check if an integer is prime. 3) Discussing advantages and disadvantages of optional dynamic polymorphism in Java methods. 4) Explaining the expected code in try, catch, and finally blocks using syntax. 5) Explaining exception propagation with a code example. 6) Defining a Person class with private data and public methods. 7) Defining a Student class that inherits from Person with additional properties and ensuring the parent constructor is called. 8) Writing a program demonstrating inheritance, overriding, over

Uploaded by

Njeru Daniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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]

You might also like