Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Faculty of Computer Studies

Course Code: M109


Course Title: .NET Programming
Summer 2021-22-Tutor Marked Assignment

Cut-Off Date: Total Marks: 80


Contents

Part I: Theoretical Questions [20 Marks]


Part II: Output and Debugging Questions [20 Marks]
Part III: Problem Solving Questions [40 Marks]

Plagiarism Warning:
As per AOU rules and regulations, all students are required to submit their own
TMA work and avoid plagiarism. The AOU has implemented sophisticated
techniques for plagiarism detection. You must provide all references in case you
use and quote another person's work in your TMA. You will be penalized for any
act of plagiarism as per the AOU's rules and regulations.
Declaration of No Plagiarism by Student (to be signed and submitted by
student with TMA work):
I hereby declare that this submitted TMA work is a result of my own efforts and I
have not plagiarized any other person's work. I have provided all references of
information that I have used and quoted in my TMA work.
Name of Student:

Signature: Date:

Part I: Theoretical Questions (4 marks each) [20 Marks]

1. A. Define .NET Framework class library.


B. List any three namespaces defined in .NET Framework class library with
description.

2. A. Briefly explain exception handling in C#.

B. List the names of any three exception classes in C# with description.

3. What is method overloading in C#? Describe the two ways to do method overloading
in C# with examples.

4. Differentiate between an abstract class and interface in C#.

5. Explain value data types and reference data types in C# with examples.

Part II: Output and Debugging Questions (10 marks each) [20 Marks]
Note: Provide a copy of the code and screen shot for the output in the solutions’

1. What is the output of the following program? [10


Marks]

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int i, j;
int [,] A = new int[5,5];
for (i = 0; i < 5; ++i)
{
for (j = 0; j < 4; ++j)
{
A[i,j] = i+j;
}
}
for (i = 0; i < 5; ++i)
{
for (j = 0; j < 4; ++j)
{
if (i < 5)
{
A[j, i] = A[i, j];
}
else
break;
Console.Write(A[i, j] + " ");

}
Console.WriteLine();
}
Console.ReadLine();
}
}

2. What is the output of the following program? [6 Marks]

namespace ConsoleApplication1
{
struct TMA
{
public int marks;
}
class Program
{
static void Main(string[] args)
{
TMA x = new TMA();
x.marks = 75;
Check(ref x);
Console.Write(x.marks + " ");
Console.ReadLine();
}
public static void Check(ref TMA y)
{
y.marks = 70;
Console.Write(y.marks + " ");
}
}
}

3. Consider the program below. Will it generate the output "Welcome to Tutor
Marked Assignment"? If no, which statement should be added in the function
BBB() of class PQR, if it is to produce the above output? [4
Marks]

namespace ConsoleApplication1
{
class XYZ
{
public void AAA()
{
Console.Write("Welcome");
}
}
class PQR : XYZ
{
public void BBB()
{
// [*** Add statement here ***]

Console.WriteLine(" to Tutor Marked Assignment");


Console.ReadLine(); }
}
class MyProgram
{
static void Main(string[] args)
{
PQR object1 = new PQR();
object1.BBB();
} }}

Part III- Problem Solving Questions [40 Marks]

Note: Provide a copy of the code and screen shot for the output in the solutions’

1. Using loops, write a C# program to print the following pattern.


[10 Marks]

2. Write a C# application that asks the user to input the required data to implement the three
methods below:
(Use Method Overloading to write the methods)
a. Method Area that takes as input, integer values ‘l’ (length) and ‘w’ (width),
calculates the area of a rectangle, and displays it. [Area = ]

b. Method Area that takes as input, double values ‘B’ (base) and ‘h’ (height),
calculates the area of a parallelogram, and displays it. [Area = ]

c. Method Area that takes as input, a double value ‘B’ (base) and an integer value
‘h’ (height), calculates the area of a triangle, and displays it. [Area = ]
[15 Marks]

Sample I/O

3. Write a C# application that asks the user to search for an item in the array. Input an array
of 10 elements and the search item. If the item is found in the array, display the location
of the item in the array. Otherwise, display appropriate error messages.

[15 Marks]

Sample I/O

M109-TMA- Summer 2021-2022


Page 2 of 6

You might also like