.NET Framework Interview Questions and Answers (547) - Page 17

Is MSIL a high/low/middle level language?



MSIL

Microsoft Intermediate Language:
It is a set of CPU independent instructions which represent your code and used to provide language interoperability and compatibility of your code on different platforms.

It is not a high level language:
High Level language is C#:
High level language is more human readable,closer to a spoken language.
(Example: programming constructs like loops,if else conditions, keywords like using, class)
High level language defines modular programming,OOPS concepts and the source code.

MSIL is not low level language either:
low level language is in an executable or binary format(eg: machine language)
MSIL is not in an executable or binary format.

MSIL is not middle level language too:
Middle level language is C. It has modular programming and source code.
It is human readable.
C also supports low level programming (Assembly Language).
Can we use static constructors to initialize non static members?

Yes, it is possible.
But we have to create an object of the class inside the static constructor and then initialize the non static member through the object reference.

Code(example):

class Class2
{
int a;
static Class2()
{
Class2 p = new Class2();
p.a = 45;
System.Console.WriteLine(p.a);
}
static void Main()
{

}
}
Which Constructor gets fired first Static or Non-Static while creating an object of a class?

Static constructor will be fired first.
Ex:
class Test{

public Test(){
Console.WriteLine(" public Test()");
}
static Test(){
Console.WriteLine(" static Test()");
}
}
class Program{
static void Main(string[] args){
Test test = new Test();
Console.Read();
}
}


Output:
static Test()
public Test()
Difference between Globalization and Localization ?

Globalization refers to formatting data in formats relevant for the current culture setting.

example:
a)consider this tag in Web.Config file.
<globalization culture="fr-FR"/>
It would cause the dates to be displayed in French for the web page of
the folder where this Web.Config file is located.

b) CultureInfo d=new CultureInfo("de-DE");
Response.Write(DateTime.Now.ToString("D",d);
It would display date in long format using German culture


Localization refers to retrieving and displaying appropriately
localized data based on the culture.
It can be done by using the Resource files.

example:
we have 2 resource files:
a)default.aspx.fr-FR.resx
b)default.aspx.en-US.resx

Using appropriate coding in the .aspx.cs files of a web page, the strings written in these resource files can be used to change the text of the strings dynamically.
Which debugging window can be used to view the variables in current and previous statements?

Autos Window is the debugging window that can be used in the condition
mentioned. When in break mode(use F10 key for that),Autos Window can be opened from the

Debug Menu-->Windows-->Autos
On which of these locations, we cannot create a breakpoint?

NOTE: This is objective type question, Please click question title for correct answer.
What are listeners?

These are the classes used to collect the output of Tracing.
The listeners write the Tracing output which they collect to a number of devices.
3 Types of listeners are there:

1)TextWriterTraceListener
It allows us to write messages to an object of the TextWriter class.

2)EventLogTraceListener:
It allows us to write messages to EventLogs

3)DefaultTraceListener:
Allows us to send messages to Output Window.

They are defined by System.Diagnostics namespace

example:
 Stream m = File.Create("dd.txt");


/*Create a TextWriterListener and then add it to the Listeners*/
TextWriterTraceListener t = new
TextWriterTraceListener(m);
Trace.Listeners.Add(t);

// Write output to the file.
Trace.Write("hello ");

Which of these editors allows us to perform searches on the target machine for a Registry key or Windows Installer components?

NOTE: This is objective type question, Please click question title for correct answer.
What are merge modules?

Merge modules are a feature of Windows Installer that can be incorporated into the setup projects of various applications and used to perform operations like
installing assemblies in the GAC.Merge modules cannot be installed directly,
They are merged into an installer for each application that uses the component.
Merge modules contain a component such as a .dll along with any related files, resources, registry entries, and setup logic.
.NET and Java J2ee Design pattern interview question :- What is the difference between Template and Strategy pattern?

Below are the main differences between these two design patterns.

Template Design pattern
Defines outline for algorithms and allows sub class to override some steps.
Efficient in terms of less redundant code.
Depends on super class for methods.

Strategy Design pattern
Uses object composition to provide variety of algorithm implementation.
Flexible in terms of allowing users to change algorithm at run time.
All the algorithms can be itself implemented.

Regards,
Do visit our .NET design pattern and Java J2EE design pattern interview questions.
How the garbage collector knows when to collect garbage ?

The garbage collector's optimizing engine determines the best time to perform a collection based upon the allocations being made. When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.
What is the difference between ASP.NET and VB.NET?

ASP.Net is a program application with server controls with programmable objects, which can do the same job HTML did in the past. ASP.Net is used to build a Website and VB.Net is a computer language you use to build the site. Some use VB.Net and others use C# (C Sharp language) to build a website. Using ASP. Net and VB.Net or C# you can build an E-commerce store, which has multi functional capabilities. You can integrate PayPal or one of the other payment programs into your site. Create an Email system, speed up the applications by caching the pages and the data within the pages of your site and do a number of other things to successfully run an E- commerce store on the Internet.

ASP.Net is very successful Web application platform used by individuals and many large companies, who want to build and run their own websites. ASP.Net provides server controls with the ability to give you rich web content and more. Anyone willing to purchase the software and learn how to properly use this technology can use the tools, and application system to build a great Website. You can develop and build your own database choosing to use VB.net or C# language. Many websites today, which were built in the past used HTML language to build their websites.
What is an application domain?

An application domain is the CLR equivalent of an operation system’s
process. An application domain is used to isolate applications from one
another. This is the same way an operating system process works. The
separation is required so that applications do not affect one another.
This separation is achieved by making sure than any given unique
virtual address space runs exactly one application and scopes the
resources for the process or application domain using that address space.
What is the difference between a strong and weak named assemblies?

1. Weak named assemblies can be duplicated and tampered with, where as strong named assemblies cannot be tampered and duplicated.

2. Strong named assemblies can be copied into GAC(GLOBAL ASSEMBLY CACHE), where as weak named assemblies cannot be copied.

3. A single copy of strong named assembly present in the GAC(GLOBAL ASSEMBLY CACHE) can be shared with multiple applications, where as weak named assembly must be copied into the bin directory of each project.



Thanks and Regards
Akiii
What are the different types of assemblies in .net?

There are two types of assemblies are there in .net. They are,
1. Private Assemblies and
2. Public/Shared Assemblies.

Private Assembly:- An assembly is used only for a particular application. It is stored in the application's directory other wise in the application's sub directory. There is no version constraint in private assembly.

Public Assembly:- It has version constraint. This public assembly is stored inside the global assembly cache or GAC.GAC contains a collection of shared assemblies.
How do we read entire contents of a file named MsgSrikanth.txt(Text File Example) into a single string variable ?


There is a text file named "MsgSrikanth.txt" which has contents. Now we can convert that entire text file into a single string variable called showResult.

That conversion is shown below :

In VB.NET
Dim showResult As String = NothingDim reader as New 

StreamReader("MsgSrikanth.txt")showResult = reader.ReadToEnd()


In C#.NET
string showResult = NothingDim;

StreamReader reader = new StreamReader("MsgSrikanth.txt");
showResult = reader.ReadToEnd();


ReadToEnd() method used to read content from the current position to the end of the file.
When does Garbage Collector generally runs?

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between rdl and rdlc

RDL:
1.Report Definition Language
2.Created by Sql server with reporting services
3.Runs on server side
4.Requires values for all elements such as query text
5.Takes less time to produce large data in reports

RDLC:
1.Report Definition Language, Client Side
2.Created by Visual studio
3.Runs on client side
4.Does not require to have values for all elements such as query text
5.Takes more time to produce large data in reports
6.As runs in local license of the reporting services not needed
Tool used to pre compile the Windows applications

NOTE: This is objective type question, Please click question title for correct answer.
Symbol used for the separators in Menu Designer

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories