C# Realtime Interview Questions and Answers:Part 1

10/14/2009 No Comment
Overview:Collection of C#.NET C Sharp Interview/Exam questions asked in various MNCs,Common C# Interview Questions, C Sharp Interview Questions and most frequently asked C# Interview Questions

1. How many types of JIT compilers are available?
There are Two types of JIT compilers.
standard JIT compiler.
EconoJIT compiler.

2.What are the different types of assemblies – name them?
Private
Public/Shared
Satellite assembly

3.What is GAC? What are the steps to be taken to pick up the latest version from GAC?
This Global Assembly Cache(GAC) stores .NET assemblies to be shared by several applications on that computer.publisher policy file is the configuration file to redirect to different version
1. Create the publisher Policy assembly using the assembly linker
2. Add the publisher policy assembly to the GAC using GACutil tool
Gacutil /i
3. During runtime CLR is looking into the publisher policy file and redirect the application to bind with new version assembly as specified inside the publisher policy.


4.How do we use different versions of private assemblies in same application without re-build?
In Asseblyinfo file need specify assembly version.
assembly: AssemblyVersion

5.Different methods of using a legacy COM component in .NET framework?
1. TLBIMP to create an Assembly from a COM component
2. Reference a COM component directly from .NET Editor

6.How do you implement SSL?
1. create certificate request
[
=>Right click on the website (VD)
=>Click Directory Security Tab and click Server Certificate
=> Type name of certificate , Organization name , server name
location info,
=> Type the path need to save certificate information Submit certificate request.
]

7.What is ref parameter? What is out parameter?
Ref Parameter: Used to pass a parameter as a reference so that the function called will set the value. This could be used to return more than 1 value by a function.
e.g.
public int AddMuliply( int a , int b, ref int c)
{
c = a*b;
return ( a+b);
}
The above function, returns the addition of two numbers as well as computes the multiplication result and passes to the calling function.
Out Parameter: Used to pass values from the aspx Code-behind to the aspx page.
The difference is that for a ref parameter, you have to assign a value before you call the function, while for OUT parameter, you dont have to assign a value, the calling function assumes that the called function would assign some value.

A ref parameter must first be initialized before being passed from the calling function to the called function. but a out parameter need not be initialized, we can pass it directly when we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect the actual variable.
even the variable passed as out parameter is same as ref parameter, but implementation in c# is different, Arguement passed as ref parameter must be initialized before it is passed to the method. But in case of out parameter it is not necessary. But after a call to a method as out parameter it is necessary to initialize.
When to use out and ref parameter, out parameter is used when we want to return more than one value from a method. Ref parameter can be used as both input and o/p parameter out parameter can be used as only output parameter

8.What is boxing? What is the benefits and disadvantages?
Boxing is converting a value-type to reference type. An example is converting an integer value to an object value.

Ex:
int intValue = 10;
object obj = (object)intValue;

This is used if you want to pass variables of object types to certain functions or methods you have created. Commonly used in events for example (Object sender...).

9.Why multiple Inheritance is not possible in C#?
Multple inheritance is coneceptually wrong. It shouldn't be allowed in any language. Inheritance is the strongest relationship that can be expressed in OO languages.
It's used to express IS-A relationship. Aggregation is used to express IS CONSTRUCTED IN TERMS OF. If you're using multiple inheritance in C++ then you're design is wrong and you probably want to use aggregation. On the other hand it's plausible to want to use multiple interfaces. For instance you might have a class wheel and a class engine. You could say that your class car inherits from wheel and from engine but that's wrong. In fact car aggregates wheel and engine because it is built in terms of those classes. If wheel is an interface and engine is an interface then car must inherit both of these interfaces since it must implement the functionaity of wheel and engine .On this basis we can see that multiple inheritance for classes should not be allowed because it promotes mis-use of the strong IS-A relationship. C# enforces the correct concepts whilst C++ allows mis-use. multiple interface inheritance is permissible and C# allows this. It's all to do with properly understanding OO concepts.

Absolute Multiple Inheritance is not possible in c# but partially it supports multiple inheritance by the use of Interfaces. As interfaces force a class to implement same type of behaviour (as defined in interface) which classes implements that interface

Related Posts


No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer