Professional Documents
Culture Documents
Mid Term - VP - Solved (1) 222
Mid Term - VP - Solved (1) 222
Marks: 10
Course Code: SE-303 Roll No: _____________________ Time: 20 Minutes Cutting,
overwriting, Erasing, Fluid Painting and use of Lead Pencil will earn no marks. Attempt all
questions of the objective portion ON the question paper.
OBJECTIVE
Question 1: Encircle the right options from the following statements.
Marks]
[10x01 = 10
Which of the following statements is correct about the C#.NET code snippet given below?
short s1 = 200;
short s2 = 400;
int a = s1 * s2;
How many times can a constructor be called during lifetime of the object?
As many times as we call it.
Only once.
Depends upon a Project Setting made in Visual Studio.NET.
Any number of times before the object gets garbage collected.
Any number of times before the object is deleted.
Which of the following statements are correct about the C#.NET code snippet given below?
int[] a = { 11, 3, 5, 9, 4 };
How will you complete the foreach loop in the C#.NET code snippet given below such that it
correctly iterate all elements of the array a?
int[] a = new int[30];
If Sample class has a Length property with get accessor then which of the following statements
will work correctly?
Sample.Length = 20;
Console.WriteLine(Sample.Length);
Which of the following will be the correct result of the statement b = a in the C#.NET code
snippet given below?;
struct Address
{
private int street;
private String city;
}
Address a = new Address();
Address b = a;
Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET?
byte
short
float
int
Visual Programming Name : _____________________ Max. Marks: 15 Course Code: SE303 Roll No: _____________________ Time: 70 Minutes SUBJECTIVE-SECTION:
Note: Attempt all questions on answer sheet. Paper interpretation itself is the part of paper, so
no query will be entertained during the exam.
Question 2:
[3 Marks]
Develop a class called Date with the following members and methods:
private data members of type int: day, month, year
properties for each private data member
methods:
2 constructors:
a default constructor that sets the date to October 1, 1979
an overloaded constructor that takes 3 arguments, and assigns them to the day, month
and year data members
A set date method, which takes 3 arguments, day, month and year and assigns them to the
data members
A print method that prints the date in traditional format "dd/mm/yyyy"
Solution:
class Date
{
private int day;
private int month;
private int year;
public Date()
{
this.day = 1;
this.month = 9;
// 1st
// October (zero based index)
this.year = year;
}
Question 3:
[2 Marks]
Create an enum Gender with values (Male, Female)
Create a struct Person with following members and methods:
private data members: id of type int, name of type string, gender of type Gender
a constructor that takes 3 arguments, and assigns them to the id, name and gender data
members
Solution:
enum Gender
{
Male,
Female
}
struct Person
{
private int id;
private String name;
private Gender gender;
Question 4:
[2 Marks]
Create a DataTable of name "Student" with following columns RollNumber, Name, Section
Add two rows in Student DataTable with following values
1, Asad, A
2, Qaisar, B
Solution:
student.Columns.Add(rollNumber);
student.Columns.Add(name);
student.Columns.Add(section);
Question 5:
[3 Marks]
Create a function for database connectivity, the function will perform the followings
You can use the query "SELECT ID, NAME, EMAIL FROM STUDENT"; assume all fields are
String types.
Solution:
/// close reader explicitly, this step is compulsory in order to free the connection object.
reader.Close();
Question 6:
[5 Marks]
Create a program which will
1- create a Rectangular array
2- copy contents of the passed Jagged array into a Rectangular array
3- return back the Rectangular array
return rArray;
}
Hint: First, you need to compute the maximum column length of the Jagged array and then
initialize the rArray
Example,
Jagged array (input)
587
63829 17
Solution:
return rArray;
}
-----------------------------------------------------------G((d
Luck-----------------------------------------------------------