Blog Archive

Theme images by Storman. Powered by Blogger.


Wednesday, July 20, 2016

C#.Net Fresher Interview Questions and Answers.

C#.Net Fresher Interview Questions and Answers. .Net Ineterview Questions and Answers For Freshers . Latest C#.Net Interview Questions For Freshers . Frequently Asked .Net Interview Questions.


What is an internal modifier?

Internal members can access only from within the same assembly (.dll).
We can declare a class as internal, its member as internal or its fields as internal.
Use internal keyword before the class declaration to create an internal class.
Internal type can't access from external program.
Classes defined within the current assembly can access internal classes.

What are namespaces, and how they are used?

In .Net framework namespaces are used to manage classes.
The Key difference between .Net namespaces and java packages is that namespace doesn’t define the physical layout of source file while java packages do.
Namespace define logical structure of the code.
Namespaces can be utilized via using keyword, in .net framework, many class have their namespace defined such as System.Net.
We can create our own C# source files which can relate to multiple projects.

Why are strings in C# immutable?

When string values changes it means string is immutable, in this whenever we assign new value to string it occupies new memory reference for its new value by creating new string instance.
String is declared by using String Keyword.
Always use mutable string defined in System.Text.StringBuilder whenever its values will change.
Inefficient use of memory and garbage collection resulted by Immutable string.

What is boxing?

When Value type is explicitly converted into reference type is called as boxing.
The reverse process is known as unboxing, when reference type is explicitly converted into value type.
In boxing process, the Values of variable is stored in Stack is converted in an object reference is stored in heap.
If the recipient reference type is equivalent to the unboxed type, then the value is copied to the heap.
Unboxing called the vice versa process of boxing.

How does C# differ from C++?

C# doesn't support multiple inheritances while C++ does.
We can use switch statement with string values in C# while in C++ only Character and integer values supported.
Casting is Safer in C# than C++.
C# doesn’t require semicolon on completion of class definition while C++ use.
In C#, Command line parameter acts differently as compared to C++.

What is the difference between public, static and void?

public: Public Modifier in C# is most liberal among all access modifiers, it can access from anywhere inside or outside other class. There is no access restriction in public modifiers .public keyword is used just before the class keyword to declare class as public.

static: Static method is used to declare main method global one and we do not need to create instance of that class. We can access methods of static class by using the class name followed by. Operator and method name .The compiler stores Static method’s address and uses this information before any object is created for execution.

void: The void modifier tells that the Main method can't return any value.

What is shadowing?

There are two ways of shadowing either through scope or through inheritance.

Hiding a method of child class and giving a new implementation is known as shadowing from inheritance.
Shadowing through inheritance is the default when a derived class implements a method of base case which is not declared as overridden in the base class.
Derived class member’s signature, return type, access level may differ from base class.
Shadowing can be obtained by using the new keyword.
Shadowing is one of the polymorphism’s concepts.

What are the difference between Structure and Class?

Structures are Values types while Classes are Reference types.
In structure values stored in stack while in class value’s reference stored in heap.
In structure direct values is stored while in class reference to a value is stored.
Inheritance is supported in classes while structure doesn’t support.
We cannot declare destructor in structure whereas in class it is possible.
We can’t have explicitly parameter less constructors in structure whereas classes can have.
Class can have protected members while structure can’t have.
Structure is declared by using struct keyword while class is declared by using Class keyword.
Structures don’t have memory management while classes have due to garbage collector.
New operator works in classes while not in structure.

How does assembly versioning work?

There is an assembly’s version called the compatibility version.
Version number is defined by four numeric parts (e.g. 5.5.3.11).
Both the name and the version of the referenced assembly are included in each reference to an assembly.
The two parts of assembly is normally seen as incompatible, but if third part is different than assemblies are deemed as ‘may be compatible’, and if the only fourth part of an assembly is different than assembly is compatible.
We can specify version policy in the application configuration file.
We cannot apply versioning to private assemblies; it is applied only to shared assemblies.

What is Custom Control?

A Custom control inherits from System.Windows.Controls.Control class.
They are compiled code (Dlls), faster to use, difficult to develop, and can be placed in toolbox.
Custom controls can be derived from different custom controls according to requirement.
Custom controls can be reused on multiple places easily.
Provide more flexibility in extending the control’s behavior.
Custom controls are loosely coupled control in respect to code an UI.
Custom controls can be used just by drag and drop into the form.
Custom controls have dynamic layout.

0 on: "C#.Net Fresher Interview Questions and Answers."