Dot Net Framework Exam Paper 1

Solved T.Y. B.B.A. (Computer Application) CA-604: DOT NET FRAMEWORK (2019 Pattern) Exam Paper

Q1) Attempt any Eight of the following:

a) What is the use of CLR?

CLR (Common Language Runtime) is the runtime environment of the .NET Framework. It is responsible for managing the execution of .NET programs, including memory management, garbage collection, exception handling, and thread management. CLR provides a layer of abstraction between the hardware and software and ensures code safety and integrity by performing tasks such as type safety and code access security.

b) What is CTS?

CTS (Common Type System) is a standard that defines the types of data that can be used in .NET programs. It defines how types are declared, used, and managed in the runtime. CTS ensures that objects written in different languages (like C#, VB.NET) can communicate with each other seamlessly.

c) Enlist any two operators in VB.NET?
  1. + (Addition Operator): Used to add two numbers.
  2. = (Assignment Operator): Used to assign a value to a variable.
d) Explain the following functions:

i) MessageBox()

MessageBox() is a method in VB.NET that displays a message box with a specified text, title, and button options. It is used to provide information or prompt user input in a GUI-based application.

ii) InputBox()

InputBox() is a method in VB.NET used to display a dialog box where the user can enter input. It returns the string entered by the user or an empty string if the user cancels the input.

e) Explain ‘this’ keyword in C#?

The this keyword in C# refers to the current instance of a class. It is used to access members (fields, methods, properties) of the current object within its instance methods. It helps to distinguish between instance variables and parameters with the same name.

f) Explain constructor and destructors in C#?

Constructor: A constructor is a special method used to initialize objects when they are created. It has the same name as the class and no return type.

Destructor: A destructor is a method used to clean up resources before an object is destroyed. It is automatically called when an object is no longer in use and is primarily used for memory management.

g) Explain server object?

Server objects are special objects in ASP.NET that are created and managed by the server. They can be used to store session or application-wide data. Examples include Session, Application, and Cache objects.

h) Explain the type of menu control?

The main types of menu controls in .NET are:

  • MainMenu: Used for creating a main menu bar at the top of a form.
  • ContextMenu: A shortcut menu that appears when the user right-clicks an object.
  • MenuStrip: Provides a flexible, menu-driven interface and is commonly used in modern applications.
i) Explain connected and disconnected architecture in ADO.NET?

Connected Architecture: In this mode, an application maintains an active connection to the database throughout the duration of a transaction. Data is retrieved and updated directly from the database.

Disconnected Architecture: In this mode, an application retrieves data into memory and can manipulate it offline (without maintaining a continuous connection). Once changes are made, they are sent back to the database in a batch update.

j) Explain Timer control in VB.NET?

The Timer control in VB.NET is used to execute code at specified intervals. It works by triggering events at regular intervals, which can be used for tasks like periodic updates, animations, or scheduled actions in an application.


Q2) Attempt any Four of the following:

a) Explain the Architecture of the .NET Framework?

The .NET Framework provides a large set of libraries and a runtime environment for building applications in different programming languages, primarily C# and VB.NET. It is designed to help developers build and deploy applications more easily.

The architecture of the .NET Framework is divided into the following major components:

  1. Common Language Runtime (CLR):
    • The CLR is the execution engine for .NET applications. It manages the execution of code, including memory management, garbage collection, exception handling, and threading.
    • It also provides a security system and makes sure that the application is safe and runs correctly.
  2. Base Class Library (BCL):
    • BCL is a collection of reusable types that provide fundamental system functionality like file I/O, string manipulation, data access, networking, and more.
    • It contains classes like System.IO for file operations, System.Data for database operations, and System.Net for networking.
  3. ASP.NET:
    • ASP.NET is a web application framework that allows you to build dynamic web pages and web applications.
    • It uses controls like TextBox, Button, GridView, etc., to help developers build websites and web services.
  4. ADO.NET:
    • ADO.NET is the data access component of the .NET Framework.
    • It provides a set of libraries and objects (like DataSet, DataTable, SqlConnection, etc.) to connect to databases, retrieve data, and perform operations like insert, update, and delete.
  5. Windows Forms:
    • Windows Forms is used to build graphical user interface (GUI) applications for desktops.
    • It provides controls like buttons, text boxes, and grids to create user interfaces.
  6. Language Interoperability:
    • The .NET Framework allows programs written in different languages (like C#, VB.NET, F#) to communicate with each other.
    • The Common Language Specification (CLS) and Common Type System (CTS) enable this interoperability by ensuring that the data types and programming languages can work seamlessly.
b) What are HTML controls?

HTML controls are elements that define the structure of a web page and allow users to interact with it. They are part of the HTML markup language and are used to display content and gather user input.

  • Examples of HTML controls:
    • <input>: Used to create input fields for users, like text fields or buttons.
    • <button>: Creates a clickable button for submitting forms or triggering actions.
    • <select>: Creates a drop-down list for selecting options.
    • <textarea>: Creates a large text box where users can enter multi-line text.
    • <label>: Defines a label for an input element.

HTML controls are rendered in the browser and are part of the client-side code. They do not perform any server-side operations directly, but they are often used in conjunction with server-side scripts (e.g., PHP, ASP.NET) to process data.

c) Explain ASP.NET basic control?

ASP.NET provides a set of server-side controls that are used to build web applications with dynamic content. These controls are processed on the server, and they generate HTML elements that are sent to the browser.

  • Common ASP.NET Controls:
    • Button: A control that triggers an event when clicked. You can use it to submit forms or perform server-side logic.
    • TextBox: A control used to get user input in the form of text.
    • Label: Displays static text or messages on the page.
    • DropDownList: A control that provides a drop-down list from which users can select a value.
    • CheckBox: A control that lets users select or deselect an option.
    • RadioButton: Used to create a list of options where only one option can be selected.
    • GridView: Displays tabular data from a data source.

These controls simplify the development of web applications by abstracting the need to write HTML code manually. The server-side controls handle their events and the user interface components automatically.

d) What is the connection object in ADO.NET?

In ADO.NET, the connection object is used to establish a connection between a .NET application and a database (such as SQL Server, Oracle, MySQL, etc.). It is represented by classes like SqlConnection (for SQL Server) or OleDbConnection (for other databases).

  • Key functions of the connection object:
    • Establishing Connection: It is used to open a connection to a database by providing a connection string that contains database server details (hostname, username, password, etc.).
    • Connection String: It contains information required to connect to the database, such as server name, database name, authentication mode, and credentials.
    • Opening and Closing: Once a connection object is created, you can open it using the Open() method and close it using the Close() method to release resources.

Example:

SqlConnection connection = new SqlConnection("Data Source=server_name;Initial Catalog=database_name;Integrated Security=True");
connection.Open();
e) Explain DataReader in ADO.NET?

The DataReader is a class used to retrieve data from a database in a forward-only, read-only manner. It provides a fast and efficient way to retrieve data row by row from the database.

  • Key Features:
    • Forward-only: DataReader can only move forward through the data. It cannot go backward, which makes it more memory-efficient.
    • Read-only: DataReader is primarily used for reading data, not modifying it.
    • Efficient: It is faster and uses less memory because it fetches data as it reads it, instead of loading the entire dataset into memory at once.

The DataReader is typically used when you want to quickly retrieve data from a database and display it on the UI.

Example:

SqlCommand command = new SqlCommand("SELECT * FROM Users", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["UserName"].ToString());
}
reader.Close();

Q3) Attempt any Four of the following:

a) Write a VB.NET program to find the maximum number among two entered numbers.
Dim num1, num2 As Integer
num1 = CInt(InputBox("Enter the first number:"))
num2 = CInt(InputBox("Enter the second number:"))
If num1 > num2 Then
MessageBox.Show("The maximum number is " & num1)
Else
MessageBox.Show("The maximum number is " & num2)
End If
  • The program takes two numbers as input from the user.
  • It then compares them and displays the larger of the two using a message box.

b) Write a VB.NET program to check whether the entered string is palindrome or not.

Dim str As Stringstr = InputBox("Enter a string:")
Dim reversedStr As String = StrReverse(str)
If str = reversedStr Then
    MessageBox.Show("The string is a palindrome.")
Else
    MessageBox.Show("The string is not a palindrome.")
End If
  • This program checks if the entered string is the same when reversed.
  • If the original string is equal to its reverse, it is a palindrome; otherwise, it’s not.

c) Write a VB.NET program to accept a number from the user through InputBox and display its multiplication table in a ListBox.

Dim number As Integer = CInt(InputBox("Enter a number:"))
For i As Integer = 1 To 10
    ListBox1.Items.Add(number & " x " & i & " = " & (number * i))
Next
  • The program prompts the user to enter a number.
  • It then generates the multiplication table of that number from 1 to 10 and displays it in a ListBox.

d) Write a C# program for the sum of two numbers.

int num1, num2, sum;
Console.WriteLine("Enter the first number:");
num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the second number:");
num2 = Convert.ToInt32(Console.ReadLine());
sum = num1 + num2;
Console.WriteLine("The sum is: " + sum);
  • This simple C# program reads two numbers from the user, calculates their sum, and displays the result.

e) Write a C# program to reverse a given number.

int num, reversedNum = 0;
Console.WriteLine("Enter a number:");
num = Convert.ToInt32(Console.ReadLine());
while (num != 0)
{
    reversedNum = reversedNum * 10 + num % 10;
    num /= 10;
}
Console.WriteLine("Reversed number is: " + reversedNum);
  • The program reverses the digits of the entered number and outputs the reversed value.
  • It uses a loop to reverse the digits by repeatedly extracting the last digit of the number and constructing the reversed number.

Q4) Attempt any Four of the following:

a) What is command object?

The Command object in ADO.NET is used to execute SQL commands (like SELECT, INSERT, UPDATE, DELETE) against a database. It can execute stored procedures or direct SQL statements.

  • Key properties:
    • CommandText: Specifies the SQL query or stored procedure name.
    • CommandType: Specifies whether the CommandText is a SQL query or a stored procedure.
    • Connection: Specifies the connection to the database.
  • Example: SqlCommand cmd = new SqlCommand("SELECT * FROM Students", connection); SqlDataReader reader = cmd.ExecuteReader();

b) Explain Event handling in ASP.NET?

Event handling in ASP.NET is the process of responding to events raised by controls or the page lifecycle. Common events include user actions like button clicks or page loading.

  • Example:
    • The Button_Click event is triggered when the user clicks a button.
    • The Page_Load event is triggered when the page is loaded on the server.

Handlers are methods that are written to handle these events.

Example:

protected void Button_Click(object sender, EventArgs e)
{
Label1.Text = "Button clicked!";
}

c) Write a C# program to swap two numbers.

int num1 = 5, num2 = 10;
Console.WriteLine("Before swap: num1 = " + num1 + ", num2 = " + num2);
int temp = num1;
num1 = num2;
num2 = temp;
Console.WriteLine("After swap: num1 = " + num1 + ", num2 = " + num2);
  • This C# program swaps the values of two variables using a temporary variable.

d) Write a VB.NET program to move the text “Pune university” continuously from left to right.

Timer1.Start()
Dim x As Integer = 0
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
x += 5
Label1.Location = New Point(x, Label1.Location.Y)
If x > Me.Width Then
x = 0
End If
End Sub
  • This VB.NET program uses a timer to move text continuously across the screen.

e) Write a C# program for multiplication of matrices.

int[,] matrix1 = { { 1, 2 }, { 3, 4 } };
int[,] matrix2 = { { 5, 6 }, { 7, 8 } };
int[,] result = new int[2, 2];
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
result[i, j] = 0;
for (int k = 0; k < 2; k++)
{
result[i, j] += matrix1[i, k] * matrix2[k, j];
}
}
}
Console.WriteLine("Multiplication result:");
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
Console.Write(result[i, j] + " ");
}
Console.WriteLine();
}
  • This C# program multiplies two 2×2 matrices and outputs the result.

Q5) Write short notes on Any Two of the following:

a) Method overloading in C#

  • Answer: Method overloading is the ability to define multiple methods with the same name but different parameters (type, number, or both). The compiler differentiates between them based on the method signature. It helps improve code readability and flexibility.

b) Validation Controls in ASP.NET

  • Answer: ASP.NET provides several validation controls to validate user input, such as RequiredFieldValidator, RangeValidator, RegularExpressionValidator, and CompareValidator. These controls ensure that user input is correct before being processed.

c) Data Types in VB.NET

  • Answer: VB.NET supports several data types including:
    • Integer: Stores whole numbers.
    • String: Stores text data.
    • Boolean: Stores true or false values.
    • Date: Stores date and time values.
    • Decimal: Stores precise decimal numbers.
Scroll to Top