latest Post

497 C# Single line interview Questions Part - 1

1)  What is .NET?
NET stands for Network Enabled Technology..NET is a Framework tool which supports many programming languages. Ex: VB.NET, C#.NET, F#.NET, C++.NET, J#.NET   etc

2) Explain code execution process in .NET? 


3) What is .NET Framework?
This is the general version, required to run .NET applications on Windows operating system.


4) What is Base Class Libraries?
Libraries are set of predefined functionalities. Class library means collection of classes and every class contains some predefined functions which are used to write code in .net. Base class libraries are designed by Microsoft. Without BCL we cannot write any code within the .net. So base class libraries as building blocks of programs of .NET.


5) What is CLR?
Explain its role? CLR is the core component of under .NET’s framework which is responsible conversion of MSIL code to native code and then execute of our application.


6) How many times code is compiled in .NET?
 In .NET code is compiled twice. In first compilation source code is compiled by respective language compiler and an intermediately code is generated known as MSIL.  In second compilation MSIL is converted into native code using CLR.


7) How many languages .NET supports?
.Net supports 60+ programming languages. In 60+ programming languages 9 are designed by Microsoft and remaining are designed by non Microsoft. Microsoft designed programming languages are:   VB.NET,C#.NET,F#.NET,J#.NET,C++.NET, JSCRIPT.NET, Windows Power Shell, Iron Python, Iron Ruby.


8) What is managed code and unmanaged code execution?
Managed code: code for which MSIL is generated after language compiler compilation directly executed by the CLR is known as   managed code Unmanaged code: code that has written before development of .net for which MSIL is not executed by the CLR directly.


9) What is language interoperability?
Providing code execution support that has been written in other programming language is known as language interoperability.
Source Code Language Compiler      MSIL
     CLR Native code Execute

10) What is CLS?
CLS is responsible to provide language interoperability


11) What is CTS?
At the time of compilation all language specific data types are converted into CLR’s data type .This data type system of CLR which is common to all programming languages of .net is known as common type system.


12) What is Boxing and UN boxing process?
Boxing: Converting a variable value into “Object” type value implicitly.
UN boxing: Converting the “Object” type value into variable explicitly (Using Conversion Methods).


13) What is role of JIT compiler, Explain?
 The “JIT” (Just In Time) compiler is responsible for compiling the “MSIL” code into the “Native code”. The native code is directly understandable by the system hardware.


14) How many types are available in .net Framework?
The .NET Framework is available in 3 different types: .NET Framework: This is the general version, required to run .NET applications on Windows operating system. .NET Mono Framework: This is required to run .NET applications on other operating systems like UNIX, LINUX and Solaris etc. .NET Compact Framework: This is required to run .NET applications on other devices like PDA (Personal Digital Assistants), Mobile phones and Smart phones.


15) Explain the purpose of ILDASM.exe tool?
The ildasm.exe parses any .NET Framework .exe or .dll assembly, and shows the information in human – readable format.


16) What is Assembly and Contents of Assemblies?
In .NET, when an application is compiled into a byte code called MSIL. That MSIL code is stored in an assembly. The assembly contents are:
Byte code: the code in MSIL language.  Security Information: Information about the users / user types, who can access the assembly.  Manifest: Information about the assembly, such as identification, name, version, and so on.  Versioning: the version number of an assembly.


17) What is GAC (Global Assembly Code)?
All the shared assemblies should be saved in the GAC. GAC offers the following advantages.
i) Unique identification of the shared assemblies.
ii) Avoids the DLL hell (replacement of an assembly related to one application, by another application).
iii) Faster accessibility.


18) Components of CLR?
The CLR contains the following components.
i) Security Manager / Code safety verifier.
ii) JIT Compiler
iii) Memory Manager
iv) Garbage Collector
v) Exception Manager


19) What is difference between Language and Technology?
Language: It acts as interface (mediator) between the programmer and the system. It offers some rules and regulations for writing the programs. It also offers some library, which is required for writing the programs.
Technology: It is designed for a particular purpose. For example, for development of web related applications, you have a technology called “ASP.NET”. For development of database related applications, you have another technology called “ADO.NET”.
But the technology doesn‘t offer any specific rules for writing the programs. But it offers some library.


20) What is Visual Studio? What are the versions of visual studio?
Visual studio is nothing but the Visual IDE (Integrated development Environment) which is needed to development applications with .net framework. The IDE integrates 3 Features: i) Editor ii) Compiler   iii) Interpreter

21) What are the Framework versions of .NET?
 Framework Version Editor
1.0 Visual studio 2002
1.1 Visual studio 2003
2.0 Visual studio 2005
3.0 --no editor--
3.5 Visual studio 2008
4.0 Visual studio 2010
4.5 Visual studio 2012 

22) What are the features available in different .NET framework?


23) What are the sections of the console applications?
i) Importing section – imports the required namespaces eg: using <namespace name>
ii) Namespace declaration  section – in this declares the user defined namespace eg: namespace <namespaceName> { ---- }
iii) Class declaration section -- in this declare the start up class of the project and other classes also. eg: class <className> { --- }
iv) Main ( ) method – this is the starting point of the execution.


24) What is the default start up class in the console and windows forms applications?
“Program” is the startup class in console and windows forms applications.


25) What are the features of the Main ( ) method?
i) Void:  the Main ( ) method can’t return any value unlike other methods.
ii) Static: To start the application execution Main ( ) method is to be called. So that it should be accessed without creating any object for Program class. That’s why you need to declare it as a static method.


26) What are the data types available in C#.NET?
i) Integer types: byte, short, int, long, sbyte, ushort, uint, ulong
ii) Decimal or Float types: float, double, decimal
iii) Boolean type: bool
iv) Character types: char, string
v) Root type: object


27) What are conditional statements? A block of statements that executes based upon the condition. They are of two types i) Branching ii) Looping


28) What are the Branching Control statements?  In C#.net, we have 2 Branching control statements. They are i) If  ii) switch


29) What are the looping control statements?  In C#.net, we have 4 looping statements. They are i) for ii) while iii) do – while iv) foreach


 30) What are the jump statements? In C#.net we have 3 Jump statements. They are i) goto ii) break iii) continue


31) How can write the output to the screen in console applications? You can write the output on the screen in console applications using two methods. They are i) Write( ) – displays the data in same line ii) WriteLine( )—displays the data in line by line format.


32) How can you read the input from the user in console applications? You can read the input from the user in console applications using two methods. They are i) Read( ) – reads a single character ii) ReadLine( ) – reads a string value from the keyboard.


33) How many ways are there to write the content to the console? There are two ways to write to the console. They are

i) Concatenation ii) Place holder syntax 34) Write the place holder syntax? Console.WriteLine(“{0} {1}”,var1, var2);


 35) What are the Limits of index value of place holder syntax? The place holder syntax‘s index (0 based) must be greater than or equal to “ 0 “ and less than the size of argument list.


36) What is code snippet? Code snippet is used to get skeleton for “System.Console.WriteLine( )”. Follow the steps to insert a snippet. i) Right click on the line where you want to add it. ii) Select “insert snippet” in the list. iii) Double click on “ visual C#” iv) Double click on “cw”.


 37) What is the User interfaces supports by C#.net? C#.net supports two types of user interfaces. They are i) CUI ( Console User Interface ) ii) GUI ( Graphical User Interface )


 38) What is CUI? CUI supports a blank screen with come characters only. It is not attractive for the user, that’s why it is not suitable for live projects development.


39) What is GUI? GUI supports graphical components like windows, icons, mouse pointer, tool bars, status bar, buttons, etc.


40) How can you insert a break point? To insert a break point follow steps. i) Right click on where you want to insert a break point. ii) Select “break point”. iii) Select “insert break point” option.


41) How can you release the break point step by step?  Press “F11” key to release the break point step by step.


42) What is the use of Label control? Label control is used to display static information in the form.


43) What is the use of Text Box control? Text Box control is get or set the values from the user.


 44) What is a Constructor?
? A constructor is member method of a class which is invoked automatically when an object is created to a class. ? A constructor is used to keep something ready for the object when it is created. 45)  What should be the name of a constructor? ? A Constructor name should be same name as a class name.


 46)  What is the return type of a constructor? ? A constructor does not have any return type methods and even void also.


 47)  What is the purpose of a constructor? ? A Constructor is used to initialize require values in to the data fields of the class or to pass the required value in to the data fields or to make required value in establishing  connection to data base, keeping the file open to perform some operations etc, when an object is created.


48)  List out the types of constructors? There are two type of Constructors are Present. They are  1. Instance Constructors These Instance Constructors are again four types. They are, a. Default Constructors I. User defined Constructors II. System Constructors.  b. Parameterized Constructors c. Copy Constructors d. Private Constructors.
2. Non-Instance Constructors These Constructors has only one Static Constructors.


49)  Explain about Instance constructors? In stance constructor will maintain separate instances for each member object of the class, for each object of the class.


 50)  Explain about Non-Instance constructors? Non Instance Constructor will not maintain separate instances for each data field of the class for each object of the class.


51)  What is User Defined Default constructor Explain? User defined default constructor is used to initialize required values in to the data fields. This constructor doesn’t accept any arguments or parameters. This Constructor is created by the programmer.


 52) What is System Defined Default constructor Explain?
When an object to the class is created first system will search for a constructor with in the class, if there is no constructor available within the class system will create its own constructor and will assign default values in to the Data Fields.


53)  What is the drawback of Default constructor? In the default constructor (for ex. Employee)if you create any number of objects for Employee class. All objects will be stores same type of data in their reference data fields. To overcome this drawback, we use parameterized constructor.


54)  What is Parameterized constructor Explain? ? A Parameterized Constructor accepts arguments to store the values in to the Data Fields. ? Using Parameterized Constructor we can store different set of values into different objects created to the class.


55)  What is Copy constructor Explain? ? These Constructors used to copy the data of an existing object in to newly created object. ? To copy constructor we need to pass argument that belong to our class data type.


56)  What is private constructor Explain? ? A Constructor whose accessibility is private is known as private constructor. ? If a class contains private constructor then we cannot create an object for the class outside the class.


57)  Can a constructor be overloaded?   Yes constructor is overloaded


58)  How many constructors can a class contain? A Class can have infinite Number of Constructors depending on the programmer.


 59)  Can we create an object to a class that contains private constructor? Yes we can create an object to a class that contains private constructor.


 60)  Where private constructors are used? Generally private constructors are used within the Remoting concept.


 61)  What is static constructor explain? ? Static Constructor is used to initialize static Data fields. ? To make any member of a class static, use static keyword.


 62)  Can we initialize static data fields with in the non static constructors?  No.


63)  Can we initialize non static data fields with in the static constructors? No


64)  What happens if a static data field is initialized within the non static constructor? Static data fields will lose their static nature.
65)  What happens if a non static data field is initialized within the static constructor? It is not possible to initialize a non static data field within the static constructor.


66)  What keyword is used to make any member as static? Static is the keyword used to make any member as static.


67)  How do you access static members of a class? We can access static member of a class through Class Name.


 68)  Explain the nature of static members of the class? Static data members will have maintain only one instance for any no. of objects created to the class.


 69)  Can a Static class be instantiated? No, because we cannot create object for Static Class.


70)  Where Static Constructors are used? ? Static Constructors are used initialize static Data fields.


71)  What are the features of Object Oriented programming? Any programming language to become as object oriented should follow (satisfy) the following features apart from the Class and Object. ? Abstraction ? Encapsulation ? Polymorphism ? Inheritance.


72)  What is a class Explain? A class is collections of objects and method. It is also collection of attributes and variables


73)  What is an Object Explain? Object is a instance of class, means object creates memory location for storage of class


 74)  What syntax is used to create a class? Syntax:   class ClassName { ----------- ----------- }


 75)  What is the default accessibility of a class? The default accessibility of a class is private.


76)  What syntax is used to create an object for the class? ClassName  objectName = new ClassName();


77)  What happens when an object is created to the class? Memory allocated to a class.
78) What is the Purpose of ‘new’ keyword while creating object? ClassName  ObjectName = new ClassName(); The above is the syntax for creating a object. Here “new” used to create memory allocated to a class in Heap memory area.


79)  What members a class can contain? Class contains two members. 1. Public  2. Private.


80) What is Data Fields explain? ? Data Fields is used to store the data related to the class.  ? Except Data Fields no other member of a class can store the data.


 81)  What is the default accessibility of the class members? Private is the default accessibility of the class member.


82)  What is Abstraction Explain? ? Abstraction is a process of Hiding the Implementation but providing the service.


 83)  List out the types of Abstraction? ? There are two types of abstraction available: ? Data Abstraction ? Functional Abstraction


 84) Explain what is Encapsulation? ? It’s process of Binding the member variable of a class along with member functions. ? Encapsulation can be implemented with the help of object and also Access modifiers like private, public and protected etc.


85)  Explain what is polymorphism? ? It’s derived from a Greek word, where poly means many morph means Faces / Behaviors/Forms ? Same function / operator will show different behaviors when passed different type of values or different number of values.


86)  List out the types of polymorphism? ? There are two types of polymorphism ? Static Polymorphism /Compile Time polymorphism / Early Binding ? Dynamic Polymorphism / Run Time polymorphism / Late Binding


87)  What is a sealed class? Sealed class is a class in which it is not possible to create or derived a new class.


 88)  How do you achieve static polymorphism? Static polymorphism is achieved using, i) function Over Loading (ii) Operator over Loading.


89) Explain about functions overloading? Functions Overloading is nothing but writing multiple Methods with same Name and with different argument is called Function Overloading.
90)  Explain about operator overloading? Every operator has some pre- defined work given by the designers if we assign   additional work apart from the existing work to any operator then we say operator is overloaded.


91) What are the situations that a function can be over loaded? A function with same name and same parameters name.


 92)  What is function signature explain? The signature of a method must be unique in the class in which the method is declared. The signature of a method consists of the name of the method, modifiers, types of its parameters the number of parameters.


93)  Explain what is Dynamic / Run Time polymorphism or Late Binding? Dynamic polymorphism is achieved by using (i) Function Overriding. ? Function overriding is providing new Implementation to a function with same signature. ? In general function overriding will be implemented within the derived class.


 94)  How can you achieve Dynamic polymorphism? Dynamic polymorphism is achieved by using function overriding.


 95)  What is function overriding explain? ? Function overriding is providing new Implementation to a function with same signature. ? In general function overriding will be implemented within the derived class. ? Function overriding will be done in the base and driver class.


 96)  What is a virtual function explain? When we implementing two same function in the base class and as well as in the derived class then we will use virtual function. 97)  What key word is used to make a function as virtual? “Virtual” is a keyword used to make a function as virtual.


 98)  What key word is used to override a virtual function? “Virtual” is a keyword used to override a function as virtual.


99)  Is overriding of a virtual function mandatory? Yes overriding when we are using same function in two classes.


100) Differentiate between function over loading and Function overriding?
Sr No. Function Overloading Function Overriding 1 Providing New Implementation to a function with same Name and Different Signature is known as Function Overloading Providing New Implementation to a function with same Name and Same signature is known as Function Overriding. 2 Function Overloading will be done in the Same Class Function Overriding will be done in the Base and Derived Classes. 3 This is Code refinement Technique This is Code Replacement Technique 4 No separate keywords are used to implement function Overloading
Use virtual keyword for base class function and override keyword in derived class function to implement function overriding
5 Used to implement static polymorphism
Used to implement dynamic polymorphism.

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment