Join Our Email Alerts-Subscribe
Important Note:Login & Check Your Email Inbox and Activate Confirmation Link


Enter Your Email :

Copyright Disclaimer:
Section 107 of the Copyright Act Fair Use Contents .
We are forwarding content link(s) from our website to content website & We are not serving any contents.
Main Source:Google.com.All the Content PDF link(s) is/are obtained from GoogleSearch
for the purpose of Education & Teaching Intention. Not for commercial purpose.
Technicalsymposium.com is not liable/responsible for any copyright issues.


C# Materials Free Download



What is the use of Using statement in C#? 

Answer: 

The .Net Framework provides resource management for managed objects through the garbage collector - You do not have to explicitly allocate and release memory for managed objects. Clean-up operations for any unmanaged resources should performed in the destructor in C#. To allow the programmer to explicitly perform these clean-up activities, objects can provide a Dispose method that can be invoked when the object is no longer needed. The using statement in C# defines a boundary for the object outside of which, the object is automatically destroyed. The using statement is excited when the end of the "using" statement block or the execution exits the "using" statement block indirectly, for example - an exception is thrown. The "using" statement allows you to specify multiple resources in a single statement. The object could also be created outside the "using" statement. The objects specified within the using block must implement the IDisposable interface. The framework invokes the Dispose method of objects specified within the "using" statement when the block is exited. 

44. What is jagged array in C#.Net? 

Answer: 

A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." 

A special type of array is introduced in C#. A Jagged Array is an array of an array in which the length of each array index can differ. 

Example:

1. int[][] jagArray = new int[5][]; 

In the above declaration the rows are fixed in size. But columns are not specified as they can vary. 

Declaring and initializing jagged array.

1. int[][] jaggedArray = new int[5][]; 

2. 3. jaggedArray[0] = new int[3]; 

4. jaggedArray[1] = new int[5]; 

5. jaggedArray[2] = new int[2]; 

6. jaggedArray[3] = new int[8]; 

7. jaggedArray[4] = new int[10]; 

8. jaggedArray[0] = new int[] { 3, 5, 7, }; 

9. jaggedArray[1] = new int[] { 1, 0, 2, 4, 6 }; 

10. jaggedArray[2] = new int[] { 1, 6 }; 

11. jaggedArray[3] = new int[] { 1, 0, 2, 4, 6, 45, 67, 78 }; 

12. jaggedArray[4] = new int[] { 1, 0, 2, 4, 6, 34, 54, 67, 87, 78 }; 

45. What is Multithreading with .NET?

Answer: 

The real usage of a thread is not about a single sequential thread, but rather using multiple threads in a single program. Multiple threads running at the same time and performing various tasks is referred as Multithreading. A thread is considered to be a lightweight process because it runs within the context of a program and takes advantage of resources allocated for that program.

A single-threaded process contains only one thread while a multithreaded process contains more than one thread for execution. 

System.Threading Namespace 

Like many other features, in .NET, System.Threading is the namespace that provides various types to help in construction of multithreaded applications. 

46. Explain Anonymous type in C#? 

Answer: 

Anonymous types allow us to create new type without defining them. This is way to defining read only properties into a single object without having to define type explicitly. Here Type is generating by the compiler and it is accessible only for the current block of code. The type of properties is also inferred by the compiler. 

We can create anonymous types by using “new” keyword together with the object initializer. 

Example

1. var anonymousData = new 

2. { 

3. ForeName = "Jignesh", 

4. SurName = "Trivedi" 

5. }; 

6. Console.WriteLine("First Name : " + anonymousData.ForeName); 

47. Explain Hashtable in C#? 

Answer: 

A Hashtable is a collection that stores (Keys, Values) pairs. Here, the Keys are used to find the storage location and is immutable and cannot have duplicate entries in the Hashtable. The .Net Framework has provided a Hash Table class that contains all the functionality required to implement a hash table without any additional development. The hash table is a general-purpose dictionary collection. Each item within the collection is a DictionaryEntry object with two properties: a key object and a value object. These are known as Key/Value. When items are added to a hash table, a hash code is generated automatically. This code is hidden from the developer. All access to the table's values is achieved using the key object for identification. As the items in the collection are sorted according to the hidden hash code, the items should be considered to be randomly ordered. 

The Hashtable Collection 

The Base Class libraries offers a Hashtable Class that is defined in the System.Collections namespace, so you don't have to code your own hash tables. It processes each key of the hash that you add every time and then uses the hash code to look up the element very quickly. The capacity of a hash table is the number of elements the hash table can hold. As elements are added to a hash table, the capacity is automatically increased as required through reallocation. It is an older .Net Framework type. 

Declaring a Hashtable 

The Hashtable class is generally found in the namespace called System.Collections. So to execute any of the examples, we have to add using System.Collections; to the source code. The declaration for the Hashtable is: 

1. Hashtable HT = new Hashtable (); 

48. What is LINQ in C#?

Answer: 

LINQ stands for Language Integrated Query. LINQ is a data querying methodology which provides querying capabilities to .NET languages with a syntax similar to a SQL query 

LINQ has a great power of querying on any source of data. The data source could be collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable interface. 

Advantages of LINQ

1. LINQ offers an object-based, language-integrated way to query over data no matter where that data came from. So through LINQ we can query database, XML as well as collections. 

2. Compile time syntax checking. 

3. It allows you to query collections like arrays, enumerable classes etc in the native language of your application, like VB or C# in much the same way as you would query a database using SQL. 

49. What is File Handling in C#.Net? 

Answer: The System.IO namespace provides four classes that allow you to manipulate individual files, as well as interact with a machine directory structure. The Directory and File directly extends System.Object and supports the creation, copying, moving and deletion of files using various static methods. They only contain static methods and are never instantiated. The FileInfo and DirecotryInfo types are derived from the abstract class FileSystemInfo type and they are typically, employed for obtaining the full details of a file or directory because their members tend to return strongly typed objects. They implement roughly the same public methods as a Directory and a File but they are stateful and the members of these classes are not static. 

50. What is Reflection in C#.Net? 

Answer: 

Reflection typically is the process of runtime type discovery to inspect metadata, CIL code, late binding and self-generating code. At run time by using reflection, we can access the same "type" information as displayed by the ildasm utility at design time. The reflection is analogous to reverse engineering in which we can break an existing *.exe or *.dll assembly to explore defined significant contents information, including methods, fields, events and properties. 

You can dynamically discover the set of interfaces supported by a given type using the System.Reflection namespace. This namespace contains numerous related types as follows: 

Reflection typically is used to dump out the loaded assemblies list, their reference to inspect methods, properties etcetera. Reflection is also used in the external disassembling tools such Reflector, Fxcop and NUnit because .NET tools don't need to parse the source code similar to C++. 

1) What is C-Sharp (C#)?

C# is a type-safe, managed and object oriented language, which is compiled by .Net framework for generating intermediate language (IL). 

2) Explain the features of C#?

Below are some of the features supported in C# -

• Constructors and Destructors

• Properties

• Passing Parameters

• Arrays

• Main

• XML Documentation and

• Indexers

3) List some of the advantages of C#?

Below are the advantages of C# -

• Easy to learn

• Object oriented

• Component oriented

• Part of .NET framework

4) What are IDE’s provided by Microsoft for C# development?

Below are the IDE’s used for C# development –

• Visual Studio Express (VCE)

• Visual Studio (VS)

• Visual Web Developer 

5) Explain the types of comments in C#?

Below are the types of comments in C# -

• Single Line Comment Eg : //

• Multiline Comments Eg: /* */

• XML Comments Eg : ///

8) List out the differences between Array and ArrayList in C#?

• Array stores the values or elements of same data type but arraylist stores values of different datatypes.

• Arrays will use the fixed length but arraylist does not uses fixed length like array.

9) Why to use “using” in C#?

“Using” statement calls – “dispose” method internally, whenever any exception occurred in any method call and in “Using” statement objects are read only and cannot be reassignable or modifiable. 

10) Explain namespaces in C#?

Namespaces are containers for the classes. We will use namespaces for grouping the related classes in C#. “Using” keyword can be used for using the namespace in other namespace. 

11) Why to use keyword “const” in C#? Give an example.

“Const” keyword is used for making an entity constant. We can’t reassign the value to constant.

Eg: const string _name = "Test";

12) What is the difference between “constant” and “readonly” variables in C#?

• “Const” keyword is used for making an entity constant. We cannot modify the value later in the code. Value assigning is mandatory to constant variables. 

• “readonly” variable value can be changed during runtime and value to readonly variables can be assigned in the constructor or at the time of declaration. 

13) Explain “static” keyword in C#?

“Static” keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made static. If the variable is made static then it will have a single instance and the value change is updated in this instance. 

14) What is the difference between “dispose” and “finalize” variables in C#?

• Dispose - This method uses interface – “IDisposable” interface and it will free up both managed and unmanaged codes like – database connection, files etc. 

• Finalize - This method is called internally unlike Dispose method which is called explicitly. It is called by garbage collector and can’t be called from the code. 

15) How the exception handling is done in C#?

In C# there is a “try… catch” block to handle the error.

16) Can we execute multiple catch blocks in C#?

No. Once any exception is occurred it executes specific exception catch block and the control comes out.v 17) Why to use “finally” block in C#?

“Finally” block will be executed irrespective of exception. So while executing the code in try block when exception is occurred, control is returned to catch block and at last “finally” block will be executed. So closing connection to database / releasing the file handlers can be kept in “finally” block. 

18) What is the difference between “finalize” and “finally” methods in C#?

• Finalize – This method is used for garbage collection. So before destroying an object this method is called as part of clean up activity. 

• Finally – This method is used for executing the code irrespective of exception occurred or not.

19) What is the difference between “throw ex” and “throw” methods in C#?

• “throw ex” will replace the stack trace of the exception with stack trace info of re throw point.

• “throw” will preserve the original stack trace info.

20) Can we have only “try” block without “catch” block in C#?

Yes we can have only try block without catch block but we have to have finally block.

21) List out two different types of errors in C#?

Below are the types of errors in C# -

• Compile Time Error

• Run Time Error

22) Do we get error while executing “finally” block in C#?

Yes. We may get error in finally block.

23) Mention the assembly name where System namespace lies in C#?

Assembly Name – mscorlib.dll

24) What are the differences between static, public and void in C#?

• Static classes/methods/variables are accessible throughout the application without creating instance. Compiler will store the method address as an entry point. 

• Public methods or variables are accessible throughout the application. 

• Void is used for the methods to indicate it will not return any value.

25) What is the difference between “out” and “ref” parameters in C#?

“out” parameter can be passed to a method and it need not be initialized where as “ref” parameter has to be initialized before it is used. 

26) Explain Jagged Arrays in C#?

If the elements of an array is an array then it’s called as jagged array. The elements can be of different sizes and dimensions.

27) Can we use “this” inside a static method in C#?

No. We can’t use “this” in static method.

28) What are value types in C#?

Below are the list of value types in C# -

• decimal

• int

• byte

• enum

• double

• long

• float

29) What are reference types in C#?

Below are the list of reference types in C# -

• class

• string

• interface

• object

30) Can we override private virtual method in C#?

No. We can’t override private virtual methods as it is not accessible outside the class.

Q #1) What is an Object and a Class?

Ans: A Class is an encapsulation of properties and methods that are used to represent a real-time entity. It is a data structure that brings all the instances together in a single unit. 

An Object in an instance of a Class. Technically, it is just a block of memory allocated that can be stored in the form of Variables, Array or a Collection. 

Q #2) What are the fundamental OOP concepts? 

Ans: The four fundamental concepts of Object Oriented Programming are:

• Encapsulation – The Internal representation of an object is hidden from the view outside object’s definition. Only the required information can be accessed whereas the rest of the data implementation is hidden. 

• Abstraction – It is a process of identifying the critical behavior and data of an object and eliminating the irrelevant details. 

• Inheritance – It is the ability to create new classes from another class. It is done by accessing, modifying and extending the behavior of objects in the parent class. 

• Polymorphism – The name means, one name, many forms. It is achieved by having multiple methods with the same name but different implementations. 

Q #3) What is Managed and Unmanaged code?

Ans: Managed code is a code which is executed by CLR (Common Language Runtime) i.e all application code based on .Net Platform. It is considered as managed because of the .Net framework which internally uses the garbage collector to clear up the unused memory. Unmanaged code is any code that is executed by application runtime of any other framework apart from .Net. The application runtime will take care of memory, security and other performance operations. 

Q #4) What is an Interface?

Ans: An Interface is a class with no implementation. The only thing that it contains is the declaration of methods, properties, and events.

Source: Contents are provided by Technicalsymposium Google Group Members. 
Disclaimer: All the above contents are provided by technicalsymposium.com Google Group members. 
Further, this content is not intended to be used for commercial purpose. Technicalsymposium.com is not liable/responsible for any copyright issues.

 


Download Technical Interview Materials PDF-Free Download

Technical Interview Questions and Answers Notes PDF
Placement Materials PDF-Free Download



Technicalsymposium.com-All Study Materials PDF-Free Download







Technicalsymposium.com-Free Live Support-Chat with Our Experts

Official Contact: +91-9245556793 (Whatsapp Message / SMS / Voice Call)


Our Expert team is ready to answer all your questions immediately-Feel free to speak in Tamil/English.

(Example:Events info/Lecture Notes/Off-Campus & All Jobs/Projects & All education information)

Working hrs (IST): (Morning: 10:00AM-3:00 PM) and (Evening:5:00 PM to 10:00 PM)

All Latest Question & Answer Page (FAQ)-Click here