Solved T.Y. B.B.A. (Computer Application) CA-604: DOT NET FRAMEWORK (2019 Pattern) Exam Paper
Q1) Attempt any Eight of the following (out of Ten):
a) What is CTS? Answer:
The Common Type System (CTS) defines the types of data that are supported by the .NET Framework. It provides a way for different .NET languages to communicate with each other by ensuring that the types they use are common and consistent.
b) State any two advantages of .NET.
- Language Interoperability: .NET allows you to write code in different languages (C#, VB.NET, F#) and still be able to work together seamlessly.
- Cross-platform Support: With the introduction of .NET Core, .NET applications can be run on different platforms such as Windows, Linux, and macOS.
c) What is Event Driven Programming?
Event-driven programming is a programming paradigm in which the flow of the program is determined by events, such as user actions (mouse clicks, key presses) or messages from other programs or threads. In .NET, events are central to interaction with the user interface.
d) Explain the difference between menu and popup menu in .NET. Answer:
- Menu: A menu is a structured list of options presented to the user, typically at the top of an application window (e.g., File, Edit, View menus).
- Popup Menu: A popup menu, also called a context menu, is a menu that appears when a user right-clicks on a specific area of the interface, offering options related to that context.
e) List any two properties of Radio Button Control. Answer:
- Checked: Determines whether the radio button is selected or not.
- Text: Sets or gets the text label displayed next to the radio button.
f) What do you mean by value type and reference type? Answer:
- Value Type: Variables hold the actual data. Examples include int, float, char.
- Reference Type: Variables hold a reference (memory address) to the data. Examples include object, string, and arrays.
g) What is boxing in C#? Answer:
Boxing is the process of converting a value type (such as an int) into a reference type (such as an object). This allows value types to be treated as objects. Example: int a = 5; object obj = a;
.
h) What is meant by ADO.Net? Answer:
ADO.NET (ActiveX Data Objects .NET) is a set of classes in .NET used to access data sources such as databases. It provides methods for connecting to databases, executing commands, and retrieving data in a disconnected manner using DataSet and DataReader.
i) Enlist any four data types used in .NET. Answer:
- int: Represents an integer.
- double: Represents a double-precision floating-point number.
- string: Represents a sequence of characters.
- bool: Represents a Boolean value (true or false).
j) What is the use of ‘this’ keyword in C#? Answer:
The this
keyword refers to the current instance of the class. It is used to access instance members (variables and methods) of the current object, especially when the parameter names are the same as the instance variables.
Q2) Attempt any Four of the following (explain in detail):
a) Explain ASP.NET page life cycle in detail.
The ASP.NET page life cycle consists of the following stages:
- Page Request: When a user requests a page, ASP.NET begins processing the page request.
- Page Initialization: During this phase, each control on the page is initialized, and its properties are set to their defaults.
- Load: In this stage, if the page has been loaded from a previous request, it retrieves the saved state information (view state).
- Postback Event Handling: If the page is a postback (i.e., submitted by the user), any events associated with controls on the page are handled.
- Rendering: The page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page.
- Unload: After the page has been fully rendered, sent to the client, and fully processed, it’s unloaded from memory.
b) What are the classes in ADO.Net? Explain in detail.
ADO.NET provides the following primary classes:
- Connection: Establishes a connection to the database (e.g.,
SqlConnection
for SQL Server). - Command: Represents a SQL statement or stored procedure to be executed against a data source (e.g.,
SqlCommand
). - DataReader: Provides a way to read data from a database in a forward-only, read-only manner (e.g.,
SqlDataReader
). - DataAdapter: Used to fill a
DataSet
orDataTable
with data from the database (e.g.,SqlDataAdapter
). - DataSet: Represents an in-memory cache of data retrieved from the database and can work in a disconnected mode.
c) How to create menus in VB.Net?
To create a menu in VB.NET:
- Drag and drop a MenuStrip control onto the form.
- Add items to the MenuStrip by right-clicking on it and selecting Edit Items.
- Define the Click events for each menu item to perform specific actions.
Dim menuStrip As New MenuStrip()
Dim fileMenu As New ToolStripMenuItem("File")
Dim exitMenuItem As New ToolStripMenuItem("Exit")
AddHandler exitMenuItem.Click, AddressOf Me.ExitMenuItem_Click
fileMenu.DropDownItems.Add(exitMenuItem)
menuStrip.Items.Add(fileMenu)
Me.MainMenuStrip = menuStrip
Me.Controls.Add(menuStrip)
Private Sub ExitMenuItem_Click(sender As Object, e As EventArgs)
Application.Exit()
End Sub
d) Enlist and explain various objectives of .NET frameworks.
- Language Interoperability: The .NET Framework allows multiple programming languages to work together seamlessly, enabling code written in different languages to interact.
- Simplified Application Development: The framework provides a unified programming model, reducing the complexity of developing Windows, web, and mobile applications.
- Robust Security: .NET offers a security model with strong encryption, authentication, and authorization mechanisms.
- Consistent Data Access: Through ADO.NET, .NET provides a consistent way to access and manipulate data, irrespective of the underlying database system.
- Memory Management: The CLR (Common Language Runtime) provides automatic garbage collection, helping to manage memory allocation and cleanup.
e) State and explain various statements used in VB.Net.
- If…Else: Used for decision-making.
- For…Next: Used for looping with a defined number of iterations.
- While…End While: Used for looping when the condition is true.
- Do…Loop: Used for looping, with a condition checked at the beginning or end.
- Select Case: Used to perform multiple checks based on a given value.
Example:
If x > 10 Then
MessageBox.Show("X is greater than 10")
Else
MessageBox.Show("X is less than or equal to 10")
End If
Q3) Attempt any Four of the following (out of Five):
a) Write a program in C# for multiplication of two numbers.
using System;
class Program
{
static void Main()
{
int num1, num2, product;
Console.Write("Enter first number: ");
num1 = int.Parse(Console.ReadLine());
Console.Write("Enter second number: ");
num2 = int.Parse(Console.ReadLine());
product = num1 * num2;
Console.WriteLine("The product of {0} and {1} is: {2}", num1, num2, product);
}
}
b) Write a program in C# to calculate the area of a square. Answer:
using System;
class Program
{
static void Main()
{
double side, area;
Console.Write("Enter the side length of the square: ");
side = double.Parse(Console.ReadLine());
area = side * side;
Console.WriteLine("The area of the square is: " + area);
}
}
c) Write a VB .NET program to check if a given number is a palindrome or not. Answer:
Dim num, reverseNum, remainder, originalNum As Integer
originalNum = Convert.ToInt32(InputBox("Enter a number:"))
num = originalNum
reverseNum = 0
While num > 0
remainder = num Mod 10
reverseNum = reverseNum * 10 + remainder
num = num \ 10
End While
If originalNum = reverseNum Then
MessageBox.Show("The number is a palindrome.")
Else
MessageBox.Show("The number is not a palindrome.")
End If
d) Write a VB.NET program to print yesterday’s date on screen. Answer:
Dim yesterday As DateTime = DateTime.Now.AddDays(-1)
MessageBox.Show("Yesterday's date was: " & yesterday.ToShortDateString())
e) Write a VB.NET program to display Student ID, Student Name, Student Course, and Student Fees. Answer:
Dim studentID As Integer = 101
Dim studentName As String = "John Doe"
Dim studentCourse As String = "Computer Science"
Dim studentFees As Double = 15000.50
MessageBox.Show("Student ID: " & studentID & vbCrLf &
"Student Name: " & studentName & vbCrLf &
"Student Course: " & studentCourse & vbCrLf &
"Student Fees: " & studentFees)
Q4) Attempt any Four of the following (out of Five):
[4 x 4 = 16]
a) What are the HTML controls? Explain. Answer:
HTML controls are elements used in HTML to create the user interface of a web page. Examples include:
- : Used for accepting user input.
- : Used to create buttons that the user can click.
- : Used for creating dropdown lists.
- : Used for multi-line text input.
b) Write steps to connect to a database using ADO.NET. Answer:
- Create a Connection object (e.g., SqlConnection).
- Set the ConnectionString to define the database server and credentials.
- Open the connection using conn.Open().
- Execute commands using SqlCommand and retrieve data using DataReader or DataAdapter.
- Close the connection using conn.Close().
Q5) Write a short note on Any Two of the following. (explain in detail)
[2 x 3 = 6]
a) Inheritance
Answer:
Inheritance is one of the fundamental principles of Object-Oriented Programming (OOP). It allows a new class (called the derived class) to inherit properties and methods from an existing class (called the base class). This helps in code reuse and enhances the extensibility of software.
- Base Class: Contains the common functionality.
- Derived Class: Inherits functionality from the base class and can extend or override the methods.
Example in C#:
// Base class
class Animal
{
public void Eat()
{
Console.WriteLine("This animal eats food.");
}
}
// Derived class
class Dog : Animal
{
public void Bark()
{
Console.WriteLine("The dog barks.");
}
}
class Program
{
static void Main()
{
Dog dog = new Dog();
dog.Eat(); // Inherited from Animal class
dog.Bark(); // Defined in Dog class
}
}
b) ASP.Net Server Controls
Answer:
ASP.NET Server Controls are components used in ASP.NET web applications that allow developers to build interactive web pages. These controls have the ability to generate HTML dynamically and handle events. They also provide the ability to persist state between requests.
Types of ASP.NET Server Controls:
- Standard Controls: Such as Button, TextBox, Label, DropDownList. These controls are used for creating basic web forms and capturing user inputs.
- Validation Controls: Like RequiredFieldValidator, RangeValidator, CustomValidator are used to validate user inputs on the server side.
- Data Controls: Such as GridView, Repeater, ListView for displaying and managing data.
- HTML Controls: These resemble traditional HTML elements (like
<input>
or<select>
), but they are treated as server-side controls.
Example:
<asp:Button ID="Button1" runat="server" Text="Click Me" OnClick="Button1_Click" />
c) Constructor and Destructor
Answer:
- Constructor: A constructor is a special method in a class that is invoked when an object of the class is created. It is used to initialize the object’s state (i.e., assign values to data members). Constructors have the same name as the class and do not have a return type.
Example:
class Person
{
public string Name;
// Constructor
public Person(string name)
{
Name = name;
}
}
class Program
{
static void Main()
{
Person p = new Person("John");
Console.WriteLine(p.Name); // Output: John
}
}
- Destructor: A destructor is a special method that is called when an object is destroyed. It is used to release any resources acquired by the object. In C#, destructors are automatically called by the garbage collector when the object is no longer referenced.
Example:
class Person
{
public string Name;
// Constructor
public Person(string name)
{
Name = name;
}
// Destructor
~Person()
{
Console.WriteLine("Destructor called for: " + Name);
}
}
In C#, destructors are not explicitly called. They are called automatically by the garbage collector when the object goes out of scope or is no longer referenced.