Professional Documents
Culture Documents
Avb Midsem
Avb Midsem
QUESTION 1 (5 Marks)
1. The .NET framework provides a runtime environment called……
3. Which of the following block of VB.NET identifies a block of code for which
particular exceptions will be activated?
–...1/5
situations
Answer
Me.Name = name
Me.ID = id
Me.Designation = designation
Me.Salary = salary
End Sub
Console.WriteLine($"Name: {Name}")
Console.WriteLine($"ID: {ID}")
Console.WriteLine($"Designation: {Designation}")
Console.WriteLine($"Salary: {Salary}")
–...2/5
End Sub
End Class
Module Module1
End Function
End Function
End Module
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
Catch ex As Exception
–...3/5
' Handle the exception
Finally
End Try
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:
Age = 30
End Sub
Me.Name = name
Me.Age = age
End Sub
–...4/5
End Class
–...5/5