Microsoft .NET PG DAC - Sept 21
Microsoft .NET PG DAC - Sept 21
Contents
Frame work ................................................................................................................................................................... 1
Net frame work............................................................................................................................................................. 3
C# Basic ......................................................................................................................................................................... 5
Enum ............................................................................................................................................................................. 6
Polymorphisms ............................................................................................................................................................. 8
Inheritance .................................................................................................................................................................... 8
Over rider .................................................................................................................................................................... 14
Constructor Overloading ............................................................................................................................................ 16
Property getset ........................................................................................................................................................... 18
Interface...................................................................................................................................................................... 21
Exception .................................................................................................................................................................... 25
Basic C ......................................................................................................................................................................... 28
Deligate Lambda ......................................................................................................................................................... 30
Name Method............................................................................................................................................................. 32
Assembly Coll Basic..................................................................................................................................................... 37
ADO _NET ................................................................................................................................................................... 39
ASP .............................................................................................................................................................................. 40
ENTITY ......................................................................................................................................................................... 42
MVC ............................................................................................................................................................................ 43
WCF ............................................................................................................................................................................. 52
Web API ...................................................................................................................................................................... 56
Frame work
1) Choose right option (‘s) below statements about the .NET CLR?
1. Common Language Runtime provides a language-neutral development and execution environment.
2. Common Language Runtime ensures that an application would not be able to access memory that it
is not authorized to access.
3. Common Language Runtime provides services to run managed applications.
4. Common Language Runtime The resources are garbage collected.
5. Common Language Runtime 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
1
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
2
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
1) .entrypoint
.maxstack 3
.locals ([0] int32 ValueOne,
[1] int32 ValueTwo,
[2] int32 V_2,
[3] int32 V_3)
IL_0000: ldc.i4.s 10
IL_0002: stloc.0
IL_0003: ldc.i4.s 20
IL_0005: stl
2) From which one of the following locations does the garbage collector remove objects?
a. The system registry b. The thread stack c. The managed heap
d. The global assembly cache e. The download cache
3
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
a. The Common Language Runtime (CLR) and Assemblies specify and enforce versioning rules and allow
side-by-side execution of a software component
b. The Common Language Runtime (CLR) only allows a single version of a component to be registered in the
Global Assembly Cache (GAC).
c. The Common Language Runtime (CLR) does not allow administrators to change the version of a
component that an Assembly references externally.
d. The Common Language Runtime (CLR) and Assemblies can only use the version of a component with
which they were compiled.
4) John wants to look at a human readable representation of the metadata and intermediate language (IL)
code contained in a .NET Portable Executable (PE) file. Given the above scenario, what tool from the .NET
SDK should John use?
a. ilasm.exe b. ildasm.exe c. al.exe d. dumpbin.exe
5) What is the relationship between Common Type System (CTS) and Common Language Specification
(CLS)?
a. NET Languages each offer a subset of the CTS and a superset of the CLS.
b. NET Languages each offer a superset of the CTS and a subset of the CLS.
c. NET Languages each offer either the CTS set or the CLS set.
d. NET Languages all offer the same superset of the CTS.
7) Which one of the following creates the metadata tables contained in a PE file?
a. Source code compiler b. JIT Compiler c. Class Loader d. Verifier
10) Which one of the following statements is true regarding how the .NET Framework minimizes "DLL Hell"?
a. It enforces that only one component of a given name can run on a machine at a time.
b. It only allows multiple versions of a given component to run on a machine at a time if they all are private
assemblies.
4
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
c. It allows side-by-side execution on the same machine, at the same time, or even the same process, of
any version of the same shared DLL.
d. It registers all assemblies with the COM+ catalog.
e. It registers all assemblies with the Global Assembly Cache (GA
12) The common language runtime can be thought of as the environment that manages code execution. It
provides core services, such as___________________
a. code compilation b. memory allocation
c. thread management, and garbage collection d. All of the Above
13) The .NET Framework is designed for cross-language compatibility, which means, simply, that .NET
components can interact with each other no matter what supported language they were written in
originally.
a. This level of cross-language compatibility is possible because of the common language runtime.
b. This level of cross-language compatibility is possible because of the common Type System
c. This level of cross-language compatibility is possible because of the Common Language Specification
d. d. None of the above
14) Statement A: The Common Language Specification (CLS) defines the minimum
A. standards to which .NET language compilers must conform. Statement B: CLS ensures that any source
B. code successfully compiled by a .NET compiler can interoperate with the .NET Fram
a. Statement A is True b. Statement B is true
c. Both Statements are True d. None of the above
C# Basic
1) How many Bytes are stored by ‘Long’ Datatype in C# .net?
a. 8 b. 4 c. 2 d. 1
3) Arrange the following datatype in order of increasing magnitude sbyte, short, long, int.
a. long < short < int < sbyte b. sbyte < short < int < long
c. Short < sbyte < int < long d. short < int < sbyte < long
4) Which datatype should be more preferred for storing a simple number like 35 to improve execution speed
of a program?
a. sbyte b. short c. int d. long
5
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
2) Convert.Int32 () used for datatypes and returns directly ‘0’ for null string
a. 2 b. Both 1, 2 c. 1 d. None of the mentioned
Enum
1) Which among the following cannot be used as a datatype for an enum in C#.NET?
a. short b. double c. int
2) 𝐶ℎ𝑜𝑜𝑠𝑒 𝑡ℎ𝑒 𝑐𝑜𝑟𝑟𝑒𝑐𝑡 𝑜𝑢𝑡𝑝𝑢𝑡 𝑓𝑜𝑟 𝑡ℎ𝑒 𝐶#. 𝑁𝐸𝑇 𝑐𝑜𝑑𝑒 𝑔𝑖𝑣𝑒𝑛 𝑏𝑒𝑙𝑜𝑤?
1. 𝑒𝑛𝑢𝑚 𝑑𝑎𝑦𝑠: 𝑖𝑛𝑡
2. {
3. 𝑠𝑢𝑛𝑑𝑎𝑦 = −3,
4. 𝑚𝑜𝑛𝑑𝑎𝑦,
5. 𝑡𝑢𝑒𝑠𝑑𝑎𝑦
6. }
7. 𝐶𝑜𝑛𝑠𝑜𝑙𝑒. 𝑊𝑟𝑖𝑡𝑒𝐿𝑖𝑛𝑒((𝑖𝑛𝑡)𝑑𝑎𝑦𝑠. 𝑠𝑢𝑛𝑑𝑎𝑦);
8. 𝐶𝑜𝑛𝑠𝑜𝑙𝑒. 𝑊𝑟𝑖𝑡𝑒𝐿𝑖𝑛𝑒((𝑖𝑛𝑡)𝑑𝑎𝑦𝑠. 𝑚𝑜𝑛𝑑𝑎𝑦);
9. 𝐶𝑜𝑛𝑠𝑜𝑙𝑒. 𝑊𝑟𝑖𝑡𝑒𝐿𝑖𝑛𝑒((𝑖𝑛𝑡)𝑑𝑎𝑦𝑠. 𝑡𝑢𝑒𝑠𝑑𝑎𝑦);
𝑎) − 3 0 1 𝑏) 0 1 2 𝒄) − 𝟑 − 𝟐 − 𝟏 𝑑) 𝑠𝑢𝑛𝑑𝑎𝑦 𝑚𝑜𝑛𝑑𝑎𝑦 𝑡𝑢𝑒𝑠𝑑𝑎𝑦
6
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
4. 𝑔𝑟𝑒𝑒𝑛,
5. 𝑏𝑙𝑢𝑒 = 5,
6. 𝑐𝑦𝑎𝑛,
7. 𝑝𝑖𝑛𝑘 = 10,
8. 𝑏𝑟𝑜𝑤𝑛
9. }
10. 𝑐𝑜𝑛𝑠𝑜𝑙𝑒. 𝑤𝑟𝑖𝑡𝑒𝑙𝑖𝑛𝑒((𝑖𝑛𝑡)𝑐𝑜𝑙𝑜𝑟. 𝑔𝑟𝑒𝑒𝑛);
11. 𝑐𝑜𝑛𝑠𝑜𝑙𝑒. 𝑤𝑟𝑖𝑡𝑒𝑙𝑖𝑛𝑒((𝑖𝑛𝑡)𝑐𝑜𝑙𝑜𝑟. 𝑏𝑟𝑜𝑤𝑛);
𝑎) 2 10
𝑏) 2 11 𝒄) 𝟏 𝟏𝟏 𝑑) 1 5
4) 𝐶𝑜𝑟𝑟𝑒𝑐𝑡 𝑡ℎ𝑒 𝑜𝑢𝑡𝑝𝑢𝑡 𝑓𝑜𝑟 𝑡ℎ𝑒 𝐶#. 𝑁𝐸𝑇 𝑐𝑜𝑑𝑒 𝑔𝑖𝑣𝑒𝑛 𝑏𝑒𝑙𝑜𝑤?
1. 𝑒𝑛𝑢𝑚 𝑙𝑒𝑡𝑡𝑒𝑟𝑠
2. {
3. 𝑎,
4. 𝑏,
5. 𝑐
6. }
7. 𝑙𝑒𝑡𝑡𝑒𝑟𝑠 𝑙;
8. 𝑙 = 𝑙𝑒𝑡𝑡𝑒𝑟𝑠. 𝑎;
9. 𝐶𝑜𝑛𝑠𝑜𝑙𝑒. 𝑤𝑟𝑖𝑡𝑒𝑙𝑖𝑛𝑒(𝑙); 𝑎𝑑𝑣𝑒𝑟𝑡𝑖𝑠𝑒𝑚𝑒𝑛𝑡𝑠
𝑎) − 1
𝑏) 0 𝒄) 𝒂
𝑆𝑡𝑟𝑢𝑐𝑡𝑢𝑟𝑒 𝑑) 𝑙𝑒𝑡𝑡𝑒𝑟𝑠. 𝑎
1) 𝑊ℎ𝑖𝑐ℎ 𝑜𝑓 𝑡ℎ𝑒 𝑓𝑜𝑙𝑙𝑜𝑤𝑖𝑛𝑔 𝑖𝑠 𝑎 𝑐𝑜𝑟𝑟𝑒𝑐𝑡 𝑠𝑡𝑎𝑡𝑒𝑚𝑒𝑛𝑡 𝑎𝑏𝑜𝑢𝑡 𝑡ℎ𝑒 𝐶#. 𝑁𝐸𝑇 𝑐𝑜𝑑𝑒 𝑔𝑖𝑣𝑒𝑛 𝑏𝑒𝑙𝑜𝑤?
1. 𝑠𝑡𝑟𝑢𝑐𝑡 𝑏𝑜𝑜𝑘
2. {
3. private String name;
4. private int pages;
5. private Single price;
6. }
7. book b = new book();
a. New structure can be inherited from struct book
b. When the program terminates, variable b will get garbage collected
7
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
Polymorphisms
1) The capability of an object in Csharp to take number of different forms and hence display behaviour as
according is known as:
a. Encapsulation b. Polymorphism c. Abstraction d. None of the mentioned
Inheritance
1) Which procedure among the following should be used to implement a ‘Is a’ or a ‘Kind of’ relationship
between two entities?
a. Polymorphism b. Inheritance c. Templates
2) In Inheritance concept, which of the following members of base class are accessible to derived class members?
a. Static b. protected c. private d. shared
5) If no access modifier for a member of a class is specified, then class member accessibility is defined as?
a. Public b. protected c. private d. internal
6) using System;
class shape
{
public int H; public int W; public shape(int h, int w)
{ H = h;
8
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
W = w;
}
public double area()
{ return 0; }
}
class rectangle :shape
{ public rectangle(int p, int q) : base(p, q) { } public double area()
{ return H * W; }
}
class triangle:shape
{ public triangle(int p, int q) : base(p, q) { } public double
area() { return (H * W)/2.0; }
}
class Program
{ static void Main(string[] args)
{ shape s1 = new triangle(5, 5);
Console.WriteLine (s1.area()); shape s2 = new rectangle
(5, 5); Console.WriteLine(s2.area());
Console.ReadLine (); }
}
}
a. 25,12.00 b.12.05,25 c.0,0 d. None
8) using System;
namespace ConsoleApplication7
{
abstract class shape
{
public int H; public int W;
10
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
11
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
class Program
{ static void Main(string[] args)
{ shape s1 = new rectangle (5, 5);
Console.WriteLine (s1.area()); shape s2 = new
triangle (6, 6);
Console.WriteLine(s2.area());
Console.ReadLine ();
}
}
a. 25, 18 b. 0, 0 c. 0, 15 d. None
Method Overloading
1) The process of defining two or more methods within the same class that have same name but different
parameters list?
a) Method overloading b) method overriding c) Encapsulation d) None of the mentioned
3) What is the process of defining a method in terms of itself that is a method that calls itself?
a) Polymorphism b) Abstraction c) Encapsulation d) Recursion
4. {
5. return(l * b * h);
6. }
7. }
a) 1000 0 100 b) 0 0 100 c) compile time error d) 1000 98.125 100
4. int j = 6;
5. add(ref i);
6. add(6);
7. Console.WriteLine(i);
8. Console.ReadLine();
9. }
10. static void add(ref int x)
11. {
12. x = x * x;
13. }
14. static void add(int x)
15. {
16. Console.WriteLine(x * x * x);
17. }
a) Compile time error b) 25 0 c) 216 0 d) 216 25
Over rider
4) What will be the output for the given set of code?
class A
{
public virtual void display()
{
Console.WriteLine("A");
}
1) Which keyword is used to declare a base class method while performing overriding of base class methods?
a) This b) virtual c) override d) extend
2. The process of defining a method in subclass having same name & type signature as a method in its superclass
is known as?
a) Method overloading b) Method overriding c) none of the mentioned
class Program
{
static void Main(string[] args)
{
A obj1 = new A();
B obj2 = new B();
A r;
r = obj1;
r.display();
r = obj2;
r.display();
Console.ReadLine();
}
}
a) A, A b) B, B c) Compile time error d) A, B
15
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
Constructor Overloading
1) What will be the output of the given set of code?
1. class maths
2. {
3. public int length;
4. public int breadth;
5. public maths(int x, int y)
6. {
7. length = x;
8. breadth = y;
16
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
9. Console.WriteLine(x + y);
10. }
11. public maths(double x, int y)
12. {
13. length = (int)x;
14. breadth = y;
15. Console.WriteLine(x * y);
16. }
17. }
18. class Program
19. {
20. static void Main(string[] args)
21. {
22. maths m = new maths(20, 40);
23. maths k = new maths(12.0, 12);
24. Console.ReadLine();
25. }
26. }
a) 60, 24 b) 60, 0 c) 60, 144 d) 60, 144.0
22. Console.ReadLine();
23. }
24. }
a) 8, 8 b) 0, 2 c) 8, 10 d) 7, 8
Property getset
1) Select the correct statement about properties of read and write in C#.NET?
a) A property can simultaneously be read or write only
b) A property can be either read only or write only
c) A write only property will only have get accessor
d) A read only property will only have set accessor
17. int l;
18. l = p.number1 + 40;
19. int k = l * 3 / 4;
20. Console.WriteLine(k);
21. Console.ReadLine();
22. }
23. }
a) 30 b) 75 c) 80 d) 0
7. Console.ReadLine();
8. }
9. }
a) 0 b) Compile time error c) 60 d) none of the above mentioned
5) Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want
the statement b.sum = 10 to fail.Which of the following is the correct solution to ensure this functionality?
a) Declare sum property with both get and set accessors
b) Declare sum property with only get accessor
c) Declare sum property with get, set and normal accessors
d) None of the mentioned
6) Consider a class maths and we had a property called as sum. b which is the reference to a maths object and
we want the statement Console. WriteLine (b.sum) to fail. Which among the following is the correct solution
to ensure this functionality?
a) Declares sum property with only get accessor
b) Declares sum property with only set accessor
c) Declares sum property with both set and get accessor
d) Declares sum property with both set, get and normal accessor
7. Consider a class maths and we had a property called as sum.b is a reference to a maths object and we
want the code below to work. Which is the correct solution to ensure this functionality? b. maths = 10;
Console. WriteLine(b.maths);
a) Declare maths property with get and set accessors
b) Declare maths property with only get accessors
c) Declare maths property with only set accessors
d) Declare maths property with only get, set and normal accessors
Interface
1) Which statement correctly defines Interfaces in C#.NET?
a) Interfaces cannot be inherited
b) Interfaces consists of data static in nature and static methods
c) Interfaces consists of only method declaration
d) None of the mentioned
2) A class consists of two interfaces with each interface consisting of three methods. The class had no instance data.
Which of the following indicates the correct size of object created from this class?
a) 12 bytes b) 16 bytes c) 0 bytes d) 24 bytes
21
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
4) Which of the following is the correct way of implementing an interface addition by class maths?
a) class maths : addition {} b) class maths implements addition {}
c) class maths imports addition {} d) None of the mentioned
7) using System;
interface I1
{ void A();
} interface I2 { void A();
} class C : I1, I2
{ public
void A()
{
Console.WriteLine("C.A()");
}
}
Class entry
{ static void main(){
C c = new C();
I1 i1 = (I1)c;
I2 i2 = (I2)c;
}
c.A();
I1.A();
I2.A();
}
What will be the output of the program.
A. C.A() C.A() A()
B. c.A(); i2.A();
i1.A();
C.Error
D. None
22
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
8) using System;
interface I1
{ void A(); } interface I2 { void A(); }
class C : I1, I2 { public void A() {
Console.WriteLine("C.A()"); }
void I1.A()
{ Console.WriteLine("I1.A()"); }
}
Class entry
{ static void main(){
C c = new C();
c.A(); I2 i2 = c;
c.A();}}
a. C.A(),C.A() b. C.A(),I1.A() c.I1.A(),C.A() d. None Q8
9) using System;
interface I1
{ void A();} interface I2
{ void A();}
class
C : I1, I2
{ void I1.A()
{ Console.WriteLine("I1.A()"); }
}
Class entry
{ static void main(){
C c = new C(); c.A();
}}
a. Compile time Error b. I2.A () c. Run time Error d. none
23
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
B.None
C. Init B B.F
Init A
A.F
D.Error
24
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
Exception
1) Which among the following is NOT an exception?
a) Stack Overflow b) Arithmetic Overflow or underflow
c) Incorrect Arithmetic Expression d) All of the above mentioned
2) Select the statements which describe the correct usage of exception handling over conventional error handling
approaches?
a) As errors can be ignored but exceptions cannot be ignored
25
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
b) Exception handling allows separation of program’s logic from error handling logic making software more
reliable and maintainable
c) try – catch – finally structure allows guaranteed clean up in event of errors under all circumstances
d) All of the above mentioned
9) Which of the following is the correct statement about exception handling in C#.NET?
a) Finally clause is compulsory
b) A program can contain multiple finally clauses
c) The statement in final clause will get executed no matter whether an exception occurs or not
d) All of the above mentioned
12. When no exception is thrown at runtime then who will catch it?
a) CLR b) Operating System c) Loader d) Compiler
Basic C
1) ________ pops up a list of methods that can be called on that object,instead of typing the full method
name.
a) Intelligence b) intelligence c) goodsense d) intellisense
2) C# supports all the key object oriented concepts such as encapsulation inheritence and polimorphism
a. True b. False
7) In an enum type each of the name constant should necessarily have an ___
type.
28
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
29
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
Deligate Lambda
1) To Handel exception in C# you must use
a. Try catch block b. Only try c. Try – finally d. None
3) A. An anonymous method cannot access ref or out parameters of the defining method.
B. An anonymous method cannot have a local variable with the same name as a local
a. Only B is true b. only A is true c. none d. both statements are true
{
public int add(int p, int q)
{
return p + q;
}
public int mul(int p, int q)
{
return p * q;
}
}
class Program
{
static void Main(string[] args)
{
myclass m = new myclass(); addition a =delegate(int p,int q){int r; r=p+q;
return r;}; a += delegate(int p, int q) { int r; r = p * q; return r; };
Console.WriteLine(a.GetInvocationList().Length);
int invo = a(3, 5);
Console.WriteLine(invo);
Console.ReadLine();
}
}
}
a.2, 15 b.15,8 c. Error d. none
9).Using system;
Delegat bool isEven(int x);
Class myclass
{ public static void Main()
31
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
{
isEven isEven = n => n % 2 == 0;
// Now, use the isEven lambda expression Console.WriteLine("Use isEven lambda expression:
");
for(int i=1; i <= 3; i++) if(isEven(i))
Console.WriteLine(i + " is even."); } }
Name Method
1) using System; class Program {
static void Main(string[] args)
{ mycall("vita"); mycall("vita",55);
Console.ReadLine(); }
static void mycall(string message, int age =25)
{
Console.WriteLine("{0}", message);
Console.WriteLine("{0}", age);
}
}
a. Vita, 25 ,vita, 55 b.Vita,vita,55 c. Error d.Vita,55,vita,25
2) using System;
class Program
{
static void Main(string[] args)
{
DisplayFancyMessage(message: "vita", age: 25,addr: "juhu");
Console.ReadLine();
}
static void DisplayFancyMessage(int age,string message, string addr)
{
Console.WriteLine(message);
Console.WriteLine("{0} {1}",age,addr);
}
}
32
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
3) using System;
class Program
{
static void Main(string[] args)
{
DisplayFancyMessage(message= "vita", age= 25,addr= "juhu");
Console.ReadLine();
}
Console.WriteLine(message);
Console.WriteLine("{0} {1}",age,addr);
}
}
}
a. vita,juhu,25 b. Error c. juhu,vita,25 d. runtime error
5) class Program
{
static void Main(string[] args)
{
DisplayFancyMessage( "Wow! Very Fancy indeed!", 50, name:"raj");
DisplayFancyMessage( "geeta", message: "hello",50);
Console.ReadLine();
}
static void DisplayFancyMessage( string message, int number, string name,) { Console.
WriteLine("{0},{1},{2}",number, name, message );
}
}
a. Error b.50, geeta, hello c.hello,geeta,50 d. none
33
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
{
EnterLogData(message:”Error”,string owner = "Programmer", DateTime timeStamp = DateTime.Now)
Console.ReadLine();
}
34
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
}
class Program
{
static void Main(string[] args)
{
myclass m = new myclass(6,6);
35
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
}
class Program
{
static void Main(string[] args)
{
myclass m = new myclass();
10) Generics provide better performance because they do not result in boxing or unboxing penalties when
storing value types.
a. True b. False
11) Generics are not type safe because they can contain different type you specify.
a. True b. False
12) To help overcome the limitations of a simple array, the .NET base class libraries ship with
a. Thread class b. Collection class c. None d. Connection class
13) Collection classes are built to dynamically resize themselves on the fly as you insert or remove items
a. True b. False
37
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
15) When creating a C# Class Library project, what is the name of the supplementary file that Visual
Studio.NET creates that contains General Information about the assembly?
a. AssemblyInfo.xml b. AssemblyInfo.cs
c. AssemblyInformation.cs d. AssemblyAttributes.cs
16) Which of the following is a value type, and not a reference type?
a. array b. delegate c. enum d. class
20) Which keyword is used in C# to prevent a class from being inherited by another class?
a. override b. protected c. sealed d. NotInheritable
21) C# types are defined in ____________, organized by ____________, compiled into __________, and
then grouped into ____________.
a. files, modules, namespaces, assemblies
b. files, namespaces, assemblies, modules
c. files, assemblies, namespaces, modules
d. files, namespaces, modules, assemblies
23) Which of the following is true for a special member of the class namely ‘this’
a. this cannot be used in a static method
b. this cannot be used in a class A to access a member of class B
c. The this member can never be declared: it is automatically implied when you create a class d. All the
above are correct
e. None of above
38
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
ADO _NET
1) To use the .NET Framework Data Provider for SQL Server, an application must reference the
_____________ namespace.
a) System.Data.Client b) System.Data.SqlClient
c) System.Data.Sql d) None of the mentioned
4). Syntax for closing and opening the connection in ADO.net is : a) sqlConn.Open() and sqlConn.close()
b) sqlConn.open() and sqlConn.Close()
c) sqlConn.Open() and sqlConn.Close()
d) None of the mentioned
6) _____________ is a bridge between a DataSet and data source for retrieving and saving data.
1. DataControler 2. DataCommand 3. DataAdapter 4. None
8) When we need to retrieve only a single value from the Database,which Method is efficient
a. ExecuteReader() b. ExecuteScalar() c. ExecuteNonQuery() d. ExecuteXmlReader()
9) If we are not returning any records from the database which method is used
39
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
ASP
1) What does ASP stand for?
a. All Standard Pages b. Active Server Pages c. A Server Page d. Active Standard Pages
2) What attribute must be set on a validator control for the validation to work?
a.Validate b. ValidateControl c. ControlToBind d. ControlToValidate
6) What class does the ASP.NET Web Form class inherit from by default?
a. System.Web.UI.Page b. System.Web.UI.Form
c. System.Web.GUI.Page d. System.Web.Form
12) How do you get information from a form that is submitted using the "post" method?
a. Request.QueryString b. Request.Form c. Response.write d. Response.writeln
13) Which object can help you maintain data across users?
a. Application object b. Session object c. Response object d. Server object
14) Which of the following ASP.NET object encapsulates the state of the client?
a. Session object b. Application object c. Response object d. Server object
15) Which of the following control is used to validate that two fields are equal?
a. RegularExpressionValidator b. CompareValidator
c. equals() method d. RequiredFieldValidator
18) When an .aspx page is requested from the web server, the out put will be rendered to browser in
following format.
a. HTML b. XML c. WML d. JSP
20) Does the EnableViewState allows the page to save the users input on a form?
a. Yes b. No
41
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
ENTITY
1) Which of the following is True?
a. Entity Framework is an ORM framework.
b. Entity Framework is an open source ORM framework.
c. Entity Framework is database mapping tool.
d. Entity Framework is object mapping tool.
2) A pattern of loading related data where a query for one type of entity also loads related entities as part of
the query is called:
a. Lazy loading b. Eager loading c. Explicit loading d. Quick Loading
4) What window in Visual Studio display CSDL, MSL and SSDL of Entity Framework?
a. Model window b. Model Browser c. EDM Designer d. Solution Explorer 5)
Which of the following is TRUE?
a. DbContext can not be used in Code First approach
b. ObjectContext is a wrapper around DBContext
c. DbContext is a wrapper around ObjectContext
d. DbContext is a sealed class which cannot be override.
8) An XML-based language that describes the storage model of an Entity Framework application is called
a. SSDL b. CSDL c. EDM d. MSL
9) An XML-based language that describes the mapping between the conceptual model and storage model of
an Entity Framework Application is called
a. SSDL b. CSDL c. EDM d. MSL
11) Which of the following is NOT TRUE about the Entity Framework?
a. It automatically generates the classes from the model and updates these classes dynamically when the
model is changed.
b. It takes care of database connectivity.
42
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
14) Which interface you have to implement to get the reference of ObjectContext from DBContext? a.
IObjectContextAdapter b. IDBContextAdapter
c. IEntityObjectContext d. IObjectContext
15) An API that can be used to configure a Code First model is called:
a. Fluent API b. CLR API c. POCO API d. T4 Template
MVC
1) MVC stands for ______.
a. Model, Vision & Control b. Model, View & Controller
c. Model, ViewData & Controller d. Model, Data & Controller
43
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
16) Which of the following default class is used to configure all the routes in MVC?
a. FilterConfig b. RegisterRouteConfig c. RouteConfig d. MVCRoutes
17) Which of the following method of html helper generates html control based on the data type of
specified property?
44
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
25) In which format data can be return from XML into table ?
A) DataSet B) Datatable C) A and B D) None
45
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
35) The Razor View Engine uses to render server side content.
A) @ B) <%= %> C) Both A & B D) None
36) The ASPX View Engine uses to render server side content.
A) @ B) <%= %> C) Both A & B D) None
37) Which is more faster between ASPX View Engine and Razor View Engine.
A) ASPX View Engine B) Razor View Engine C) Both A & B D) None
38) Does Razor Engine supports for TDD ?
A) Yes B) No C) None
By default routing is defined under Global.asax file. MVC ASP.Net uses routing to map between incoming
browser request to controller action methods.
43) Can be it possible to share single view across multiple controllers in MVC?
Answer: We can put the view under shared folder, it will automatically view the across the multiple
controllers.
44) Are MVC and Web API merged into one in MVC 6?
A) Yes B) No C) Both A & B D) None
46) Does MVC 6 allow only save change, hitting the save but then refreshing the browser to reflect changes?
A) Yes B) No C) Both A & B D) None
47) Does vNext is now Open Sourced via the .NET Foundation and open to public contributions.
A) Yes B) No C) Both A & B D) None
48) Can vNext runs on both Mac and Linux today (Mono Version)?
A) Yes B) No C) Both A & B D) None
52) Does Viewstart override all Views layout/template under "Views" folder in MVC ?
A) Yes B) No C) Both A & B D) None
54) Can we use third party View Engine using ASP.Net MVC Engine ?
Yes, below are the top five alternative ASP.Net MVC View Engines.
1. Spark (Castle MonoRail framework projects), Open Sourced, it is popular as MVCContrib library.
47
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
57) Which is the way to render Partial View using ASP.Net MVC Razor Engine?
A) @Html.Partial("_PartialHeader")B) @Html.PartialView("_PartialHeader") C)
@Html.PartialHtml("_PartialHeader")
D) B and C
E) None
48
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
64) Does TempData used to pass data from one page to another page in MVC?
A) Yes B) No C) Both A) & B) D) None
66) Does Web API (ASP.Net) supports to non SOAP based like XML or JSON ?
A) Yes B) No C) None
67) Does Web API (ASP.Net) supports to both version mobile apps and others ?
A) Yes B) No C) Both A & B D) None
68) Can ASP.Net Web API, it works HTTP standard verbs like POST, GET, PUT, DELETE (CRUD Operations) ?
A) Yes B) No C) Both A & B D) None
69) Can ASP.Net Web API ability to both self hosting (outside of IIS) and IIS ?
A) Yes B) No C) None
70) Can ASP.Net Web API has ability to transport non HTTP protocols like TCP, UDP, Named Pipes etc ?
A) Yes B) No C) None
49
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
D) All
75) What is the difference between HtmlTextbox and HtmlTextboxFor using ASP.Net MVC Razor Engine?
A) @Html.TextBox is not strongly typed, @Html.TextBoxFor is strongly typed that is why should be use
@Html.TextBoxFor in MVC Razor Engine.
B) @Html.TextBox is strongly typed, @Html.TextBoxFor is not strongly typed that is why should be use
@Html.TextBox in MVC Razor Engine.
C) None
D) Both A and B
76) What is the benefits of Html.RenderPartial using ASP.Net MVC Razor Engine? A)
@Html.RenderPartial Returns response, moreover requires to create action.
B) @Html.RenderPartial Returns nothing (void), it is faster than @Html.Partial, moreover requires not to
create action. C) None
D) Both A and B
77) What is the benefits of Html.Partial using ASP.Net MVC Razor Engine?
A) @Html.RenderPartial Returns response, moreover requires to create action.
B) @Html.RenderPartial Returns string value, it is slower than @Html.RenderPartial, moreover requires
not to create action.
C) None
D) Both A and [email protected]("_viewname");
78) How to check Request coming from which controller using MVC ASP.Net?
A) var _controller = HttpContext.Current.Request.RequestContext.Values["Controller"].ToString(); B)
var _controller =
HttpContext.Current.Request.RequestContext.RouteData.Values["Controller"].ToString(); C)
var _controller = RouteData.Values["Controller"].ToString();
D) None
80) Which Name space is used to create chart using ASP.Net MVC?
A) using System.Web.MVC; B) using System.Web.Helpers;
c) using System.Web.Chart; D) All
82) Which name space using can send email in ASP.Net MVC?
A) using System.Net.Mail; B) using System.Net;
C) using System.Mail; D) None
50
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
83) If Razor View Engine need to add JQuery function and contain @ special character then how we can
write it in Razor View?
A) Replace @ to @@@ (tripple) B) Replace @ to @@ (double)
C) None D) Both (A & B)
84) How to set Default Value to Hidden Input Box using ASP.Net MVC?
A) @Html.HiddenFor(m => m.Name, "Jack")
B) @Html.HiddenFor(m => m.Name, new { Value = "Jack"})
C) @Html.Hidden(m => m.Name, new { Value = "Jack"})
D) None
91) Can you list the main types of result using ASP.Net MVC?
There are total 10 main types of result, ActionResult is main type and others are sub types of results as listed
below:
• System.Web.Mvc.ActionResult
• System.Web.Mvc.ContentResult
• System.Web.Mvc.EmptyResult
• System.Web.Mvc.FileResult
• System.Web.Mvc.HttpStatusCodeResult
• System.Web.Mvc.JavaScriptResult
• System.Web.Mvc.JsonResult
• System.Web.Mvc.RedirectResult
• System.Web.Mvc.RedirectToRouteResult
• System.Web.Mvc.ViewResultBase
WCF
1. Which of the following is NOT true?
A) A WCF Service can be consumed by Windows applications
B) A WCF Service can be consumed by Web applications
C) A WCF Service can perform calculations
D) A WCF Service cannot return a dataset
3. The standard method for storing data that can be transferred easily from one machine or platform to
another is _______.
A) XML B) SOAP C) WSDL D) WCF
4. One of the advantages of using _______ is that data are transmitted in a text format rather than a binary
format.
A) XML B) SOAP C) WSDL D) WCF
5. Data that is in _______ format can pass through many firewalls that _______ cannot penetrate.
A) binary, text B) text, binary C) SOAP, WCF D) WCF, SOAP
6. _______ is a popular standard that includes a set of rules for handling requests and responses
including class names, method names, and parameters.
A) XML B) WCF C) WSDL D) SOAP
7. The information about the names of the methods, the parameters that can be passed, and the values that
are returned from the functions is controlled in some Web services by a description specified in _______.
A) XML B) SOAP C) WSDL D) WCF
8. Always end your URI (or URL) with a ________ to avoid an extra trip to the server to determine that it is a
site rather than a directory.
A) hyphen B) slash C) backslash D) double slash
9. A resource on the Web is uniquely identified by its URI, which means _______.
52
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
10. To add a WCF Service, select the solution name in the Solution Explorer and select _______ from File
menu.
A) Add / New Solution B) Add / New Web Site
C) Add / New Service D) Add / New Library
11. You have created a new service based on Windows Communication Foundation and also a client
application to test the service. You want add an endpoint in the web.config file of the client application to
use the new service. Which values should you include in you service element of the web.config file? A.
Address B. Contract C. Binding D. All of these
12. A service contract specifies what an endpoint communicates to the outside world. At a more
concrete level, it is a statement about a set of specific messages organized into basic message exchange
patterns (MEPs), such as request/reply, one-way, and duplex. Which of the following is NOT part of the
Service Contract specification:
A. The data types of messages B. The specific protocols and serialization formats C.
The location of the operations D. The frequency of messages per second
13. Services are groups of operations. To create a service contract you usually model operations and specify
their grouping. In Windows Communication Foundation (WCF) applications, developers define the
operations by creating a method and marking it with the which attribute? A. ServiceContractAttribute
B. DataMemberAttribute
C. DataContractAttribute D. OperationContractAttribute
14. You’ve created a new class in your .NET project that contains a wide variety of operations grouped
together to form part of a Server Contract. You now need to add an attribute to the class to define it as a
service contract. Which attribute should you use?
A. OperationContractAttribute B. DataMemberAttribute
C. DataContractAttribute D. ServiceContractAttribute
15. Both classes and interfaces represent a grouping of functionality and, therefore, both can be used to
define a WCF service contract. However, it is recommended that you use interfaces because they directly
model service contracts. Without an implementation, interfaces do no more than define a grouping of
methods with certain signatures. Which of the following is a benefit of using interfaces to define Service
Contracts?
A. Service contract interfaces can extend any number of other service contract interfaces.
B. You can modify the implementation of a service contract by changing the interface implementation, while
the service contract remains the same
C. A single class can implement any number of service contracts by implementing those service contract
interfaces.
D. All of these
16. You have created a new class which will be the basis for a Service Contract. You have used
53
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
ServiceContractAttribute and OperationContractAttribute to decorate the class and the methods. Which of
the following is NOT an advantage of using classes instead of interfaces for Service Contracts?
A. Speed B. All of these are disadvantages
C. Simplicity D. Multiple Inheritance
17. Which of the following is TRUE regarding service operations and references to objects?
A. Objects must be serializable B. You can’t return values from service operations
C. Objects are passed as references D. You can’t pass parameters to service operations
18. You’ve created a new class and decorated it with the DataContractAttribute so that it forms a Data
Contract for WCF. This class contains several attributes that you want to make available as part of the Data
Contract. Currently these attributes are declared as private. What do you need to do to ensure these
attributes are serializable?
A. Add the DataMemberAttribute and change the type to public
B. Add the DataContractAttribute to the attribute
C. Change the type to internal
D. Add the DataMemberAttribute or change the type to public
19. A developer has designed a service that contains a method called TakeAction which is decorated with the
following attribute:
[OperationContractAttribute(IsOneWay=true)]
Another client application will invoke the TakeAction operation and continue processing after WCF writes
the message to the network. What must the developer of the TakeAction method do to ensure the client
action can call this method?
A. Use object as the return type B. Use FaultException as the return type C.
Remove all parameters from the method signature D. Use void as the return type
20. The signature of a service operation dictates a certain underlying message exchange pattern (MEP) that
can support the data transfer and the features an operation requires. You want to adopt a pattern that
supports the sending and receiving of messages by both the service and client. Which patter should you
choose?
A. one-way B. none of these C. request/reply D. duplex
22. A client application interacts with a new Service that calculates interest rates for the banks customers.
The Service Contract contains BasicHttpBinding as the binding type in the endpoint configuration. The
service contains some methods that return sensitive information such as customers names and addresses.
You want to ensure that these methods are encrypted. What should you do?
A. Set the ProtectionLevel to None in the ServiceContractAttribute
B. Set the ProtectionLevel in the OperationContractAttribute to EncryptAndSign for each of the sensitive
methods
54
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
24. In Windows Communication Foundation (WCF) applications, which of the following is FALSE regarding
Sessions?
A. Messages delivered during a session are processed in the order in which they are received
B. They are explicitly initiated and terminated by the receiving application
C. There is no general data store associated with a WCF session
D. D. Sessions correlate a group of messages into a conversation
26. When configuring a WCF service using Visual Studio, you can use either a Web.config file or an
App.config file to specify the settings. The choice of the configuration file name is determined by the hosting
environment you choose for the service. Where does the endpoint configuration element lie in a .NET
configuration file?
A. System.ServiceModel – bindings – endpoint
B. System.ServiceModel – services – service – endpoint
C. System.ServiceModel – endpoint
D. System.ServiceModel – behaviors – behavior – endpoint
28. Which class in WCF represents the unit of communication between endpoints in a distributed
environment?
A. RequestContext B. Message C. Binding D. ChannelBase
28. Windows Communication Formats (WCF) is Microsoft’s technology for communicating between
applications on the same computer system, on a network, or across the
A. True B. False
A. True B. False
30. WCF cannot communicate with other platforms that support SOAP and simple XML.
A. True B. False
32. Data that is in binary format can pass through any firewall.
A. True B. False
33. WSDL contains information about the names of the methods, the parameters that can be passed, and
the values that are returned from the functions.
A. True B. False
34. For technical specifications, the industry standard term URL is preferred to URI.
A. True B. False
36. To rename a Web Service you need to change only the name in the Solution Explorer.
A. True B. False
37. When a new project is added to a WCF Service solution, the projects are saved independently.
A. True B. False
Web API
3. Q.12) Web API supports which of the following request/response data formats by default?
a) JSON b) XML c) BSON d) All of the above
6. Web API uses which of the following open-source library for JSON serialization?
a) Json.NET b) JsonFormatter.NET c) GetJson.NET d) None of the above
9. Which of the following types are valid response types of Web API 2 action method?
a) HttpResponseMessage b) IHttpActionResult
c) Custom types d) All of the above
10. Web API sends which of the following status code on successful execution?
a) 200 b) 201 c) 500 d) 404
12. Which of the following property returns all the formatters in Web API?
a. GlobalConfiguration.Configuration.JsonFormatter
b. Configuration.Formatters
c. GlobalConfiguration.Formatters
d. GlobalConfiguration.Configuration.Formatters
14. Web API extract the values of primitive type parameters of an action method from _____ by default.
a) HTTP Request Body b) HTTP Header
c) Message Header d) Query String
15. Web API extract the values of complex type parameters of an action method from _____ by default.
a) HTTP Request Body b) HTTP Header
c) Message Header d) Query String
16. By default, Web API sends HTTP response with which of the following status code for all uncaught exception?
a) 404 - Not Found b) 500 - Internal Server Error
57
USM’s Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC Sept 21 Microsoft .NET Question Bank
17. Which of the following is used to check the validity of the model in Web API?
a) Mode.Valid b) Model.IsValid
c) ModelState.IsValid d) ModelState.Valid
58