Professional Documents
Culture Documents
• Polymorphism
1. Abstraction
• Class (2marks)
• State four advantages of object oriented languages over the other languages. (4marks)
•
(ii) Stave four rules for naming variables in C++/ java. (4marks)
(iii) Using example demonstrate how variables are declared and initialized in Java/C++.
(4marks)
Question 2 (20marks)
Question 3 (20marks)
• Rewrite the program given below using switch case selection control structure construct. (6marks)
char letter;
String country;
if(letter ==”A”)
country=”Algeria”;
else if(letter=”B”)
country=”Botswana”;
else if(letter=”G”)
country=”Gabon”;
else
cout<<“Sorry no match for your letter”;
• Write a program is required to calculate net pay for a casual worker. The user inputs the number of days worked and daily pay
using keyboard input. A tax of 16% is deducted from the payable amount. Write a complete program that computes the payable
amount, tax deducted and the net pay and display the results. De�ne functions to compute each of the results.
(8marks)
• Explain the di�erence between local and global variables as used in C++. Use example code.
(6marks)
Question 4 (20marks)
(6marks)
• Design a class program for a The class consist the following member variables: Student ID, Student Names, Course and Semester fee.
The methods include: getStudentDetails (for initializing the student details) and displayStudentDetails (for printing the student details
on the screen). The class contains one object Mystudent.
(12marks)
Question 5 (20marks)
(a) A program is required to compute grades for student performance in OOP. The user inputs the marks scored in the unit to get
the grade. The grading system is as follows:
Marks Grade
0 – 39 Fail
(c) Using examples codes, discuss three types of loops used in programming. (9marks)