JOMO KENYATTA UNIVERSITY OF AGRICULTURE AND
TECHNOLOGY
University Examinations 2022/2023
YEAR II SEMESTER I END OF SEMESTER EXAMINATION FOR THE DIPLOMA IN
INFORMATION TECHNOLOGY
DIT 0303: PROGRAMMING DESKTOP APPLICATIONS
DATE: APRIL 2023 TIME: 1½ HRS
INSTRUCTIONS: Answer ANY THREE Questions
QUESTION ONE
a) Explain why VB.NET is considered to be object-oriented and also event-driven programming
language. [4 marks]
b) Explain the difference between the following controls used in VB.NET. [6 marks]
i) List box and Combo box
ii) Checkbox and Radio button
iii) Textbox and Label
c) Write TWO different VB.NET statements that would perform each of the following tasks.
[8
marks]
i) Output the value in the variable perimeter
ii) Increment the value of variable h by 1
iii) Input the date of birth of a person and store it in variable dob
iv) Make the statement “This is VB.NET” a comment in your code.
d) Using a valid example, describe the syntax of For…Next loop. [2 marks]
QUESTION TWO
a) Using strictly Do…Until Loop, write a console application that displays the following
pattern. [6 marks]
|| ||
|| ||
|| || || || ||
|| ||
|| ||
b) Consider a program that should compute the surface area and volume of the sphere. The
program should use Class Sphere that has procedure to compute and return surface area, and
a procedure to compute and return the volume. Class Sphere should inherit from Class Shape
Page 1 of 2
that has fields’ radius, surface area and volume, and procedure print that prints both surface
area and volume. Given that surface area = 4πr2 and Volume =4/3πr3 , do the following:
i) Write code for the Class Shape. [4 marks]
ii) Write code for the Class Sphere. [6 marks]
iii) Write a driver program to test your code. [4 marks]
QUESTION THREE
a) The two roots of a quadratic equation ax2 + bx + c = 0 can be obtained using the following
formula
x=−b ±
√((bxb)¿−4 ac) ¿
2a
b2 - 4ac is called the discriminant of the quadratic equation. Sketch the interface and write a
program that prompts the user to enter values for a, b, and c using separate Textboxes and
displays the result on a Label based on the discriminant once button compute is clicked. If the
discriminant is positive, display two roots. If the discriminant is 0, display one root. Otherwise,
display “The equation has no real roots”.
[10 marks]
b) In DIT 2.1 class, there are 20 students and each is taking 6 units.
i) Declare an array that will store their names. [2 marks]
ii) Declare an array that will store the marks scored by each student in each unit.
[3
marks]
iii) Write code segment that will capture names and marks and store them appropriately
in respective arrays. [5
marks]
QUESTION FOUR
a) Exceptions are runtime errors that cause premature termination of a program.
i) Explain how they are handled in VB.NET. [4 marks]
ii) Write a program that accept the date of birth of a purpose then display the age.
Structure your code such that any possible runtime error is captured, reported and
user requested to perform a remedial activity.
[8 marks]
b) Distinguish between the following terms as applied in VB.NET. Use sample code where
necessary. [8 marks]
i) ReDim and Preserve
ii) CDbl and CStr
iii) Overriding and overloading
iv) Get and Set
Page 2 of 2