Computer Science Examination S6
Computer Science Examination S6
Page 1 of 4
9. Write a C++ program using class called Rectangle and an object called rect. This class should
have four members: two data members of type int with private access and two member
functions with public access: set_values() and area(). Set_values() to input the values of
rectangle and area() to return the area of rectangle. (4Marks)
10. What do you understand by Paging? Give advantages and disadvantages of paging in memory
management? (6Marks)
11. a. Differentiate memory and storage (2Marks)
b. State any four features of ROM and RAM (4Marks)
12. Write a Java program that do the following: (5Marks)
• Create linkedList from linked list with assigned to the variable district.
• Add the following district in the List (Gakenke, Rubavu, Gasabo, Nyagatare,Nyabihu )
• Add Bugesera District to the front of list and Karongi to the 4th position
• Replace Gasabo District with Nyarugenge
• Retrieving the Second District using Index
• Show the Size and Remove the last district in the List
Page 2 of 4
17. Knowing that the formula to compute the volume of cylinder is v=pi*(r^2)*h where v=
volume; pi=22/7; r=radius and h=height. Using Function Write a required code to make
program that calculates the volume of cylinder using the VB interface as designed bellow:
When you run the program, you should be able to see the interface as shown in. If you enter a
value each in radius box and the height box, then click OK; the value of volume will be
displayed in the volume box. (10marks)
SECTION C: ATTEMPT ONLY ONE QUESTION /15MARKS
18. a. Why visual basic is an event driver programming language? (2marks)
b. List the components of visual basic application. (3marks)
c. Write a visual basic program that compute the following tasks according to the interface
bellow. (10marks)
• If a user checks the first option (Add), the program should display the addition of the
numbers entered in the Text 1 and Text 2 in the text3 if a user clicks to a button
compute.
• If a user checks the second option (Multiplication), the program should display the
addition of the numbers entered in the Text 1 and Text 2 in the text3 if a user clicks to
a button compute.
• If a user checks the third option (Subtraction), the program should display the addition
of the numbers entered in the Text 1 and Text 2 in the text3 if a user clicks to a button
compute.
Page 3 of 4
• If a user checks the fourth option (Division), the program should display the addition
of the numbers entered in the Text 1 and Text 2 in the text3 if a user clicks to a button
compute.
• The program should display nothing in Text1,Text2 and text 3 if a user clicks to a clear
button
• Remember the program should be closed when the user clicks on exit button