0% found this document useful (0 votes)
54 views12 pages

Constructors in C#.NET: Key Concepts

The document is an examination question paper for the module CS6004ES, titled Application Development, scheduled for July 11, 2024. It includes instructions for candidates, a warning about unauthorized materials, and a breakdown of the exam structure, which consists of multiple-choice questions in Section A and descriptive questions in Section B. The paper covers various topics related to C# and ASP.NET, including concepts like managed code, inheritance, and testing methodologies.

Uploaded by

dimanranwaka
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views12 pages

Constructors in C#.NET: Key Concepts

The document is an examination question paper for the module CS6004ES, titled Application Development, scheduled for July 11, 2024. It includes instructions for candidates, a warning about unauthorized materials, and a breakdown of the exam structure, which consists of multiple-choice questions in Section A and descriptive questions in Section B. The paper covers various topics related to C# and ASP.NET, including concepts like managed code, inheritance, and testing methodologies.

Uploaded by

dimanranwaka
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Examination question paper: May 2023 (Resit)

Module code: CS6004ES

Component number: Exam


Module title: Application Development

Module leader: Mr. Chamila Karunathilake

Date: 11th July 2024 Thursday

Start time: 2.00pm – 4.00pm

Duration: 2 hours

Exam type: Unseen

Materials supplied: None

Materials permitted: None


Warning: Candidates are warned that possession of
unauthorised materials in an examination is a serious
assessment offence.

Instructions to This exam is worth 40% of the assessment for the module.
candidates: Candidates MUST answer the SECTION A with 30 MCQ
questions (compulsory)
Each question carries 2 marks.

Answer Question One and any other Question from two and
three from Section B. Each question carries 20 marks
No credit will be given for attempting further questions.
If you use supplementary sheets, tie them up at the end of
your booklet but inside the cover sheet of the booklet.

DO NOT TURN PAGE OVER UNTIL INSTRUCTED


© London Metropolitan University

Page 1 of 12
SECTION A
Q-1 Which of the following statements are TRUE about the .NET CLR?
1. It provides a language-neutral development & execution environment.
2. It ensures that an application would not be able to access memory that it is not authorized to
access.
3. It provides services to run "managed" applications.
4. The resources are garbage collected.
5. It provides services to run "unmanaged" applications.
A. Only 1 and 2
B. Only 1, 2 and 4
C. 1, 2, 3, 4
D. Only 4 and 5

Q-2 Which of the following statements is correct about Managed Code?


A. Managed code is the code that is compiled by the JIT compilers.
B. Managed code is the code where resources are Garbage Collected.
C. Managed code is the code that runs on top of Windows.
D. Managed code is the code that is written to target the services of the CLR.

Q-3 Select the output for the following set of Code for n= 5342

1. static void Main(string[] args)


2. {
3. int n, r;
4. n = Convert.ToInt32([Link]());
5. while (n > 0)
6. {
7. r = n % 10;
8. n = n / 10;
9. [Link](“ ”,r);
10. }
11. [Link]();
12. }

A. 3245 B. 2354 C. 2345 D. 5423

Q-4 Which of the following statements is correct about constructors in C#.NET?

A. Constructor cannot be declared as private B. A constructor cannot be overloaded


C. A constructor can be a static constructor D. None of the mentioned

Page 2 of 12
Q-5 When user request a web page by entering Uniform Resource Locator (URL) then which
method /verb/command is used in [Link]?

A. POST B. SET C. GET


D. All of the above.
Q-6 Which of the following is the root of the .NET type hierarchy?
A. [Link] C. [Link]
B. [Link] D. [Link]
Q -7 Correct statement about inheritance in C# .NET? Write a sample C# code and explain the
object construction in the inheritance hierarchy.

A. In inheritance chain, object construction begins from base class towards derived class
B. Inheritance cannot extend base class functionality
C. A derived class object contains all non-private attributes and behaviours in the base class
data
D. All of the mentioned

Q-8 Which of the following constitutes the .NET Framework?

[Link] Applications
CLR
Framework Class Library
WinForm Applications
Windows Services
A. 1,2 B. 2,3 C. 3,4 D.2,5

Q-9 The process of defining a method in subclass having same name & type signature as a method
in its superclass is known as? Explain the concept with a sample C# Code.

A. Method overloading
B. Method overriding
C. Method hiding
D. None of the mentioned

Page 3 of 12
Q-10 Which of the following statements is correct about the C#.NET code snippet given below?
class Student s1, s2; // Here 'Student' is a user-defined class.
s1 = new Student();
s2 = new Student();

A. Contents of s1 and s2 will be exactly same.


B. The two objects will get created on the stack.
C. Contents of the two objects created will be exactly same.
D. The two objects will always be created in adjacent memory locations

Q-11 Which of the following is the correct way to create an object of the class Sample?
1. Sample s = new Sample();
2. Sample s;
3. Sample s; s = new Sample();
4. s = new Sample();

A. 1,3 B. 2,4 C.1,2,3 D. 1,4


Q-12 Choose the correct statements among the following. Explain the abstract class and an abstract
method with a sample C# code.

A. An abstract method does not have implementation


B. An abstract method can be declared only in abstract class
C. None of the above
D. both a & b

Q-13 In C#.NET if we do not catch the exception thrown at runtime then which of the following
will catch it?
A. Compiler [Link] C. Linker D. Loader

Page 4 of 12
Q-14 What would be the output of following code?
{
try
{
int i, sum;
sum = 10;
for (i = -1 ;i < 3 ;++i)
{
sum = (sum / i);
[Link] ("{0} ",i);
}
}
catch(ArithmeticException e)
{
[Link]("0");
}
[Link]();
}

A. -1
B. 0
C. -1 0
D. -1 0 -1

Q-15 Which of the following statements is correct about the C#.NET code snippet given below?
class Sample
{
private int i;
public Single j;
private void DisplayData()
{
[Link](i + " " + j);
}
public void ShowData()
{
[Link](i + " " + j);
}
}

A. j cannot be declared as public.


B. DisplayData() cannot be declared as private.
C. DisplayData() cannot access j.
D. There is no error in this class.

Page 5 of 12
Q-16 Which of the following should be used to implement a 'Has a' relationship between two
entities?
A. Polymorphism B. Templates C. Containership D. Encapsulation
Q-17 What are the Command Object Methods IN [Link]?
D. ExecuteNonQuery B. ExecuteReader C. ExecuteScalar D. All of the above.

Q-18 Which of the following statements is correct about the C#.NET code snippet given below?
int i;
int j = new int();
i = 10;
j = 20;
String str;
str = [Link]();
str = [Link]();

A. This is a perfectly workable code snippet.


B. Since int is a primitive, we cannot use new with it.
C. Since an int is a primitive, we cannot call the method ToString() using it.
D. i will get created on stack, whereas j will get created on heap.

Page 6 of 12
Q – 19 If a class Student has an indexer, then which of the following is the correct way to declare
this indexer to make the C#.NET code snippet given below work successfully?
Student s = new Student();
s[1, 2] = 35;

A. class Student
{
int[ ] a = new int[5, 5];
public property WriteOnly int this[int i, int j]
{
set
{
a[i, j] = value;
}
}
}

B. class Student
{
int[ , ] a = new int[5, 5];
public int property WriteOnly
{
set
{
a[i, j] = value;
}
}
}

C. class Student
{
int[ , ] a = new int[5, 5];
public int this[int i, int j]
{
set
{
a[i, j] = value;
}
}
}

D. class Student
{
int[ , ] a = new int[5, 5];
int i, j;
public int this
{
set
{
a[i, j] = value;
}
}
}

Page 7 of 12
Q-20. If Sample class has a Length property with get and set accessors then which of the following
statements will work correctly?

1 [Link] = 20;

2 Sample m = new Sample();


[Link] = 10;

3 [Link]([Link]);

4 Sample m = new Sample();


int len;
len = [Link];

5 Sample m = new Sample();


[Link] = [Link] + 20;

A. 1, 3 B. 2, 4, 5 C. 4 only D. 3, 5
Q-21 Which of the following are reuse mechanisms available in C#.NET?

1. Inheritance 2. Encapsulation 3. Templates 4. Containership 5. Polymorphism

A. 1, 4 B. 1, 3 C. 2, 4 D. 3, 5
Q-22 Which of the following statements is correct about the C#.NET program given below if a
value "6" is input to it?
using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
int index;
int val = 44;
int[] a = new int[5];
try
{
[Link]("Enter a number:");
index = Convert.Tolnt32([Link]());
a[index] = val;
}
catch(FormatException e)
{
[Link]("Bad Format");
}
catch(IndexOutOfRangeException e)
{
[Link]("Index out of bounds");
}
[Link]("Remaining program");
}
}
}

Page 8 of 12
A. It will output: Index out of bounds Remaining program
B. It will output: Bad Format Remaining program
C. It will output: Bad Format
D. It will output: Remaining program

Q-23 Which Of The Following Operator Can Be Used To Access The Member Function Of A
Class?

A. :
B. ::
C. .
D. #

Q-24 Which of the following statements should be added to the subroutine fun( ) if the C#.NET
code snippet given below is to output 9 13?
class BaseClass
{
protected int i = 13;
}
class Derived: BaseClass
{
int i = 9;
public void fun()
{
// [*** Add statement here ***]
}
}

A. [Link](base.i + " " + i);


B. [Link](i + " " + base.i);
C. [Link](mybase.i + " " + i);
D. [Link](i + " " + mybase.i);

Page 9 of 12
Q-25 Which statement will you add in the function fun() of class B, if it is to produce the output
"Welcome to [Link]!"?

namespace IndiabixConsoleApplication
{
class A
{
public void fun()
{
[Link]("Welcome");
}
}
class B: A
{
public void fun()
{
// [*** Add statement here ***]
[Link](" to [Link]!");
}

}
class MyProgram
{
static void Main (string[ ] args)
{
B b = new B();
[Link]();
}
}
}

A. [Link]();
B. A::fun();
C. fun();
D. [Link]();

Q-26
Which of the following is the root of the .NET type hierarchy?
A. [Link] B. [Link] C. [Link] D. [Link]

Q-27
When we write <img src="[Link]">, what "[Link]" inside double quote implies?
A. element
B. attribute
C. value
D. operator

Page 10 of 12
Q-28
Which of following is not an attribute of <form> tag
A. Action B. Method C. name D. url

Q-29
Which of the following is the correct about class member variables?
A. Member variables are the attributes of an object (from design perspective) and they are
kept private to implement encapsulation.
B. These private variables can only be accessed using the public member functions.
C. Both of the above.
D. None of the above.

Q-30
What is the most suitable web server to publish an application developed by [Link]?
A. Apache B. Internet Information Services (IIS)
C. Apache Tomcat D. Oracle weblogic

Page 11 of 12
SECTION B

Question 1

a) What is namespace in C#? (5 Marks)


b) Differentiate value type and reference type in C#. (5 Marks)
c) List out the categories of controls supported in window based application and explain the
importance of each. (5 Marks)
d) How encapsulation is implemented in C#? (5 Marks)

Question 2

a) 1) Compare ASP with [Link] (5 Marks)


b) 2) What is MVC Architecture ? (7 Marks)
c) 3) What is [Link] Web service? (8 Marks)

Question 3

a) Explain what unit testing is and how it is useful (5 Marks)


b) Explain what black box testing is and how it is useful (5 Marks)
c) Explain what White box testing is and how it is useful (5 Marks)
d) What is the difference between functional and non-functional testing? (5 Marks)

*****End of the paper*****

Page 12 of 12

Common questions

Powered by AI

Encapsulation in C# is implemented using access modifiers like private, public, and protected. It is important because it helps protect an object's integrity by preventing outside access and modification of its inner workings, thus ensuring modularity and security .

The .NET CLR provides a language-neutral development environment, ensures applications do not access unauthorized memory, runs managed applications with services like garbage collection, and supports interoperability across different programming languages .

Value types (like int, char) store data directly and are allocated on the stack, leading to faster access and automatic cleanup. Reference types (like objects, strings) store references to data on the heap, enabling complex data structures but requiring garbage collection for memory management .

Namespaces in C# are used to organize and provide a level of separation between classes, interfaces, and functions, avoiding naming conflicts. They contribute to effective software design by making code more manageable and easier to understand .

C#.NET supports reuse through mechanisms such as inheritance (allowing classes to derive from others), encapsulation (hiding details and exposing only needed functionality), and polymorphism (methods to take different forms). These forms differ in how they allow code extension, encapsulation in terms of data hiding, and polymorphism in method flexibility .

Managed code in .NET is code that is executed by the CLR, providing features like garbage collection, exception handling, and type safety, which improve application stability and security .

MVC Architecture divides an application into three interconnected components: Model, View, and Controller. This separation helps manage complex applications by promoting organized code, simplifying maintenance, and enhancing the ability to test components independently .

ASP is a scripting engine that relies on a mix of HTML, server-side scripts, and COM objects, whereas ASP.NET is a framework based on .NET which supports compiled languages like C#. ASP.NET offers enhanced performance, scalability, state management features, and supports MVC architecture, making it more robust for modern web applications .

Functional testing verifies specific actions or functions of the software, ensuring it meets requirements. Non-functional testing assesses broader aspects like performance, usability, and reliability, ensuring the software functions effectively under various conditions and user loads .

Inheritance in C#.NET starts object construction from the base class towards derived class, allowing the derived class to use non-private data and behavior from the base class. This supports reuse and polymorphism . For example: ```csharp class BaseClass { public BaseClass() { Console.WriteLine("Base Constructor"); } } class DerivedClass : BaseClass { public DerivedClass() { Console.WriteLine("Derived Constructor"); } } // Output: Base Constructor // Derived Constructor ```

You might also like