GHANA COMMUNICATION TECHNOLOGY UNIVERSITY
FACULTY OF COMPUTING AND INFORMATION SYSTEMS
Bsc INFORMATION TECHNOLOGY (LEVEL 300)
MID-SEMESTER EXAMINATIONS, JULY 2024
CICS 314: ADVANCE VISUAL BASIC PROGRAMMING
Duration:2 hours
Total Marks: 20
INDEX NUMBER 1705099688
NAME NARTEY IYKE FREMPONG
CAMPUS/BATCH LEVEL 300 TOPUP
QUESTION 1 (5 Marks)
1. The .NET framework provides a runtime environment called……
a) RMT b) CLR c)GC d)BCL
2. How does vb.net instantiates the .net object
a) Using New keyword
b) Using CreateObject Keyword
c) Using Get object
d) Both A & B
3. Which of the following block of VB.NET identifies a block of code for which
particular exceptions will be activated?
a) Try b) Finally c) Catch d) Throw
4. Using MyBase you can call base class ……
a) Constructor b) Function c) Variables d) Constants
5.……… is the ability of one program element to be used in many different
–...1/5
situations
a) Polymorphism b) Inheritance c) Data Hiding d) Object
Answer any 3 questions from Q2 to Q5
Question 2 (5 Marks)
Design a class Employee with a parameterized constructor and a procedure to display the
Name , ID , Designation and salary of an employee
Answer
Public Class Employee
Public Property Name As String
Public Property ID As Integer
Public Property Designation As String
Public Property Salary As Double
Public Sub New(name As String, id As Integer, designation As String, salary As Double)
Me.Name = name
Me.ID = id
Me.Designation = designation
Me.Salary = salary
End Sub
Public Sub DisplayEmployeeDetails()
Console.WriteLine($"Name: {Name}")
Console.WriteLine($"ID: {ID}")
Console.WriteLine($"Designation: {Designation}")
Console.WriteLine($"Salary: {Salary}")
–...2/5
End Sub
End Class
Question 3(5 Marks)
Create an overloaded function multiply
Answer
Module Module1
Function Multiply(num1 As Integer, num2 As Integer) As Integer
Return num1 * num2
End Function
Function Multiply(num1 As Double, num2 As Double) As Double
Return num1 * num2
End Function
End Module
Question 4(5 Marks)
Explain exception handling mechanism in VB.NET
Answer
In VB.NET, exception handling is crucial for managing errors and unexpected situations
that may arise during program execution. The Try...Catch...Finally block is commonly used
for handling exceptions. Within the Try block, you place the code that might generate an
exception. If an exception occurs, the control moves to the Catch block where you can
handle the exception by providing specific error-handling code. The Finally block is
optional and is used to execute code regardless of whether an exception occurs or not, like
closing files or releasing resources.
Example
Try
' Code that might raise an exception
Catch ex As Exception
–...3/5
' Handle the exception
Finally
' Clean up code
End Try
Question 5(5 Marks)
What is a constructor? How do we invoke a constructor? Give an example of
Constructor Overloading
Answer
In VB.NET, a constructor is a special method that gets called when an object of a class is
created. It initializes the object's state and allocates memory. To invoke a constructor, you
simply use the New keyword followed by the class name. Here's a simple example:
Public Class Person
Public Property Name As String
Public Property Age As Integer
' Default Constructor
Public Sub New()
Name = "John Doe"
Age = 30
End Sub
' Parameterized Constructor
Public Sub New(ByVal name As String, ByVal age As Integer)
Me.Name = name
Me.Age = age
End Sub
–...4/5
End Class
–...5/5