0% found this document useful (0 votes)
21 views14 pages

DotNET MidTerms

The document contains a series of multiple-choice questions related to C# programming concepts, including constructor overloading, code output predictions, .NET Framework details, and application development scenarios. Each question presents options for the correct answer, testing knowledge on various programming principles and syntax. The questions cover topics such as class inheritance, properties, data types, and the Global Assembly Cache (GAC).

Uploaded by

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

DotNET MidTerms

The document contains a series of multiple-choice questions related to C# programming concepts, including constructor overloading, code output predictions, .NET Framework details, and application development scenarios. Each question presents options for the correct answer, testing knowledge on various programming principles and syntax. The questions cover topics such as class inheritance, properties, data types, and the Global Assembly Cache (GAC).

Uploaded by

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

Câu 1.

Correct statement about constructor overloading in C#


is?
A. All of the mentioned
B. Overloaded constructors have the same name as the class
C. Overloaded constructors can have different type of number of
arguments as well as differ in number of arguments
D. Overloaded constructors cannot use optional arguments
Câu 2. What will be the output of the following C# code ?

using System;
namespace Exam
{
class Base
{
virtual void Func()
{
[Link]("1");
}
}
class Derived : Base
{
internal void Func()
{
[Link]("2");
}
}
class Program
{
static void Main(string[] args)
{
Base obj_base = new Base();
Derived obj_derived = new Derived();
obj_derived.Func();
[Link]();
}
}
}

A. 2
B. Runtime Error
C. 1
D. 12
E. Compile Error

Câu 3. What will be the output of the following C# code?

class number
{
private int num1 = 60;
private int num2 = 20;
public int anumber
{
get { return num1;}
set { num1 = value;}
}
public int anumber1
{
get
{
return num2;
}
set
{
num2 = value;
}}
}
class Program
{
public static void Main(string[] args)
{
number p = new number();
number k = new number();
int m = [Link];
int t = k.anumber1;
int r = [Link] * k.anumber1;
[Link](r);
[Link]();
}
}
A. 0
B. Compile Error
C. 120
D. 1200

Câu 3. You are developing a data-entry application that receives


user input in multiple data fields. The application allows users to
enter the data either by using a keyboard or by using a bar-code
scanner. When a code is entered, a picture of the product appears
onscreen. The application also needs to log its operation to a
console window. Occasionally, the operator will look at the console
window to monitor communication with the scanner. What project
should you choose to create such an application?

A. a Windows Forms application project with the Output type set to


Console Application
B. a console application project with the Output type set to Windows
Application
C. a Windows Forms application project
D. a console application project

Câu 4. Which of the following statements is correct about the .NET


Framework?

A. .NET Framework is built on the DCOM technology.


B. .NET Framework uses DCOM for achieving language interoperability.
C. .NET Framework uses DCOM for creating unmanaged applications.
D. .NET Framework uses COM+ services while creating Distributed
Applications.
E. .NET Framework uses DCOM for making transition between managed and
unmanaged code.
Câu 5. What will be the output of the following C# code?

class maths
{
int i;
public maths(int x)
{
i = x;
[Link]("hello ");
}
}
class maths1 : maths
{
public maths1(int x) : base(x)
{
[Link]("bye");
}
}
class Program
{
static void Main(string[] args)
{
maths1 k = new maths1(12);
[Link]();
}j
}

A. Compile Error
B. hello bye
C. bye 12
D. 12 hello
Câu 6. What will be the output of the following C# code?

struct abc
{
public int i;
}
class Program
{
static void Main(string[] args)
{
abc x = new abc();
abc z;
x.i = 10;
z = x;
z.i = 15;
[Link]("{0} {1}", x.i,z.i);
[Link]();
}
}

A. 10 15
B. 15 15
C. 15 10
D. 10 10
Câu 7. GAC stands for:

A. Garbage Assemble Cache


B. Global Advanced Cache
C. Global Assembly Store
D. Global Assembly Cache

Câu 8. What event does an input device initiate to determine when


the user has placed an input device over the Windows Form?

A. KeyPress
B. Leave
C. Enter
D. Click
Câu 9. What will be the output of the following C# code?

using System;
namespace Exam
{
class Program
{
static void Func(params int[] arr)
{
for (int i = 0; i < [Link]; i++)
{
arr[i] = arr[i] * 5;
[Link](arr[i] + " ");
}
}
static void Main(string[] args)
{
int[] arr = { 1, 2, 3, 4, 5 };
Func(arr);
}
}
}

A. 12345
B. 6 12 18 24 30
C. 5 10 15 20 25
D. 5 25 125 625 3125
Câu 10. For the given set of C# code, is conversion possible?

static void Main(string[] args)


{
int a = 76;
char b;
b = (char)a;
[Link](b);
[Link]();
}

A. Compiler will urge for conversion from ‘integer’ to ‘character’ data type
B. Conversion is explicit type
C. None of the mentioned
D. Compiler will generate runtime error
Câu 11. What will be the output of the following C# code ?

using System;
namespace Exam
{
interface IFace1 { void Func(); }
interface IFace2 { void Func(); }
class ClassExam : IFace1, IFace2
{
void [Link]()
{
[Link]("1");
}
void [Link]()
{
[Link]("2");
}
public void Func()
{
[Link]("3");
}
}
class Program
{
static void Main(string[] args)
{
ClassExam obj = new ClassExam();
[Link]();
}
}
}

A. Compile Error
B. 2
C. 1
D. Another Answer
E. 3
Câu 12. What will be the output of the following C# code?

class maths
{
public static void fun1()
{
[Link]("method 1:");
}
public void fun2()
{
fun1();
[Link]("method 2:");
}
public void fun2(int k)
{
[Link](k);
fun2();
}
}
class Program
{
static void Main(string[] args)
{
maths obj = new maths();
maths.fun1();
obj.fun2(20);
[Link]();
}
}

A. method 1: method 2: 20 method 1:


B. method 1: 20 method 2: method 2:
C. method 2: 20 method 1: method 1:
D. method 1: 20 method 1: method 2:
Câu 13. What will be the output of the following C# code?

static void Main(string[] args)


{
int i;
int b = 8, a = 32;
for (i = 0; i <= 10; i++)
{
if ((a / b * 2) == 2)
{
[Link](i + " ");
continue;
}
else if (i != 4)
[Link](i + " ");
else
break;
}
}

A. Another Answer
B. 0123
C. 01234
D. 012345678
E. 123456789
Câu 14. The Default value of Boolean Data Type is?

A. True
B. False
C. 1
D. 0

Câu 15. Choose the wrong statement about the properties used in
C#.NET?

A. Each property consists of accessor as get and set


B. Properties can be used to store and retrieve values to and from the data
members of a class
C. Properties are like actual methods which work like data members
D. A property cannot be either read or write only

Câu 16. You are developing an application that will be run from the
command line. Which of the following methods would you use for
getting input from to the command line?

A. [Link]
B. [Link]
C. [Link]
D. [Link]
Câu 17. What will be the output of the following C# code?

static void Main(string[] args)


{
{
var dayCode = "MTWFS";
var daysArray = new List<string>();
var list = new Dictionary<string, string>
{ {"M", "Monday"}, {"T", "Tuesday"}, {"W", "Wednesday"},
{"R", "Thursday"}, {"F", "Friday"}, {"S", "Saturday"},
{"U", "Sunday"}
};
for (int i = 0, max = [Link]; i < max; i++)
{
var tmp = dayCode[i].ToString();
if ([Link](tmp))
{
[Link](list[tmp]);
}
}
[Link]([Link]("\n ", daysArray));
}
}

A. Monday, Tuesday, Wednesday, Friday, Saturday


B. Monday, Tuesday, Wednesday, Friday, Saturday, Sunday
C. Monday Tuesday Wednesday Friday Saturday
D. Monday Tuesday Wednesday Friday Sunday
Câu 18. What will be the output of the following C# code?

using System;
namespace Exam
{
class Program
{
static void Func(ref int var_x)
{
var_x = var_x * var_x;
}
static void Main(string[] args)
{
int var_x = 5;
Func(ref var_x);
[Link](var_x);
}
}
}

A. 5
B. 0
C. 20
D. 25

Câu 19. GAC _____ ? Global Assembly Cache, CIL Common Intermidate
Language

A. Cache application data.


B. None of the above
C. Stores global dlls.
D. Stores the .net assemblies which are shared between multiple
application

You might also like