.NET Interview Question.

Post date: Mar 1, 2011 12:50:47 PM

What is the Difference between Convert.ToInt32 and int.Parse?

Int.Parse Can't Handle Null values , It will throws ArgumentNullException Error. 

 

By default how Interface members are treated?

Public and abstract

What is the default accessibility of a Class?

Internal

How many Constructors can a class contain?

More than one constructorWhich type of control inherits from the controls class without graphic representation?

Custom control

What is the difference between MVC and MVP design pattern

In MVP , the view is loosely coupled to the model and the presenter binds the view and the model. In MVC controllers are shared across the views.

Which of the following isn't a difference between class and struct?

Class is reference type where as struct is value type

Class keyword is used for Class where as struct is used for struct 

Bydeafult members are private in class where as public in struct

Both can inherit a class

Which of the following statment about .net security true?

A. Assemblies are secured by encrypting compiled IL with public key

What is Un boxing?

Encapsulating a copy of an object in a value type

What is boxing?

Encapsulating a copy of a value type in an object

What does virtual keyword mean ?

we can override that function down the line.

 

Can we declare class as private?

Yes

Can we create main method in generic Class?

Can't

Can we declare a constuctor in abstract class?

yes

 

How do you round the number 7.25, to the nearest integer?

Math. round (7.25)

What is the exception thrown when there is an attempt to dymamically access a method that does not exist?

MissingMethodException

Why is the use of interface references preferred over use of references (Ex: IDataReader and IDbConnection) whose type matches the database specific classes being created (Ex: SqlDataReader and SqlConnection)?

It makes the code more generic

Delegates are typically used to implement which design pattern?

Publish/Subscribe

Which method would be used to invoke a delegate type asynchronously in C#?

BeginInvoke()

What is the extension of multi file assembly?

.netmodule

What is the output of the following statement?

int i = 0;

Console.WriteLine(i);

for(;;)

{

if(i++ > 5)

break;

Console.WriteLine(i);

}

0123456

for(;;) specifies an infinite loop which can only be left by the commands break or return. i++ increments i after the comparision, i.e., for i == 5 this test is still not fulfilled and i is incremented to six which is printed at the next command.

Which class can be used to perform data type conversion between .NET data types and XML types

XmlConvert

 

What does #pragma do in C#?

disable specific compiler warnings

 

C# supports the following inheritance

Inheritance represents the relationship between two classes where one type derives functionality from a second type

and then extends it by adding methods, properties, events, fields and constants.

Which of the following application need not have an entry point?

Class Modules

If int? I = 2; which of the following assigns the value 2 to j?

int j = i ?? 0;

If test is a Random object, then what expression will return a value between 0 and 100?

test.Next(100)

Random.Next Method (Int32) returns a non-negative random number less than the specified maximum.

 

To determine the number of dimensions of an array at runtime, which one of the following properties do you use?

Rank

Which one is not user defined data type?

String

int, float, string are called compiler defined data types. class, struct, enumerator are called user defined data types.Can we have static indexer in C# ?

NO

 

Can two catch blocks be executed?

NO

can we have different access modifiers on get/set

methods of a property ?

NO

If we inherit a class do the private variables also get inherited ?

Yes, the variables are inherited but can not be accessed directly by the class interface

 

Can we use events with threading ?

YES

 

Example for Daemon thread

Garbage collector.

Object type collections are located in the whcih NameSpace?

System.Collections

Generic Collections are located in which Name-space?

System.Collections.Generic

Static datamembers should be initialized inside the constructor.

FALSE

Which method do you invoke on the DataAdapter control to load your generated dataset with data?

 Fill()

 

Can you edit data in the Repeater control?

No

 

Whats the .NET collection class that allows an element to be accessed using a unique key?

HashTable

Will the finally block get executed if an exception has not occurred?

Yes

Can multiple catch blocks be executed for a single try statement?

No

 

Can you store multiple data types in System.Array?

No

What the top .NET class that everything is derived from?

System.Object

Does C# support multiple-inheritance?

No

Type of code security that protects system resources from unauthorized calls

Code-based Security

 

________________ refers to formatting data based on locale.

Globalization

What are the basic techniques for creating a control?

Inheriting from an existing control

 

Inherit from UserControl

 

Inherit form Control

 

_______________ represents a drawing surface and provides methods for rendering to that drawing surface.

Graphic object

 

Can you inherit multiple interfaces?

Yes

Sealed Classes cannot be a base class.

True

Is there any errors in this -> EmployeeMgmt constructor: Public int EmployeeMgmt { emp_id = 100; }

Return type

 

Two methods with the same name but with different parameters

Overloading

Feature of a local variable

It must be declared within a method 

Which of the following Statement rethrows Exception?

throw;

 

All the C# programs must have the following statement

Interface

Can I define my own exceptions?

Yes, as long as you follow the rule that exceptions derive from System.Exception. More specifically, MS recommend that user-defined exceptions inherit from System.ApplicationException (which is derived from System.Exception).

which words combination is used to override method?

virtual,override

int x = 42;

int s = 43;

x++;

x += –s;

Console.WriteLine(x);

85