Friday, May 23, 2014

Arrays of C#.Net Interview Questions(20)

Arrays of C#.Net Interview Questions(20)





1.What is an Array?
A)Array is a collection of homogenous types under a single named instance.Array is a user defined data type.Each value location is identified using the index.Index start with 0 and ends with size-1.

2.Array belongs to which types?
A)Array belongs to reference types.

3.List the different types of Arrays?
A)Arrays can be classified into four Broad categories.They are
         1.      According To Physical Size
Ø  Single Dimensional Array
Ø  Multi Dimensional Array

        2.      According to Memory Size
Ø  Normal Array
Ø  Huge Array
       3.      According to nature of physical size
Ø  Dynamic Array
       4.      Special type
Ø  Jagged Array

4.Define Single Dimensional Array?
A)An array which contains one row or one column is known as single dimensional array.
   E.G: int [] a=new int[]{1,2,3};

5.Define Multi Dimensional Array?
A)An array which contains more than one row and more than one column is known as multi dimensional array.
   E.G: int [,] a=new int[2,3]{{1,2,3}{4,5,6}};

6.What is Normal Array?
A)An array which occupies a memory size of less than 64 KB is known as a normal array.

7.What is Huge Array?
A)An array which occupies a memory size of more than 64 KB is known as a huge array.

8.What is static Array?
A)An array whose physical size is fixed and cannot be changed at runtime is known as static array.

9.What is Dynamic Array?
A)An array whose physical size is not fixed throughout the program execution and can be changed at runtime is known as dynamic array.

10.How can we change size of an array?
A)Array size can be changed during the program execution using Resize() function of array class.

11.What is Jagged Array?
A)An Array  of Arrays is known as jagged array.
  E.G:  int[,] a=new int[,];
Note:In Jagged Arrays we can’t declare the size of the column.

12.What is the name space used for Array Class?
A)Using System.Array

13.Can you use foreach iteration on arrays in C#?
A)Yes,Since array type implements IEnumerable, you can use foreach iteration on all arrays in C#.

14.List Some of Methods under Array Class?
A)Methods in an Array class are.Listed Below
Ø  Array.Copy(Source Array,Destination Array,length)
Ø  Array.Reverse(ArrayName)
Ø  Array.Sort(ArrayName)
Ø  Array.BinarySearch(ArrayName,object value)
Ø  Array.Clear()
Ø  Array.Resize(ref variablename,ArrayName)

15.What is the return type of an Array.BinarySearch() Method?
A)Integer

16.What is an array object?
A)When we create any array with any name then array is treated as an object.
Array objevt consists of some methods and properties

17.List the properties of an array object?
A)Properties of an Array can be listed below.They are
                           Ø  Array.Length
                           Ø  Array.Rank

18.What are the methods in Array object?
A)Array objects consists of following methods.They are
                      Ø  CopyTo(DetinationArray,index)
                      Ø  Clone()

19.What is the purpose of GetLength(0) method?
A)This method is used to find number of rows of an multidimensional or jagged array

20.What is the purpose of GetLength(1) method?
A)This method is used to find number of columns of an multidimensional or jagged array

Boxing and UnBoxing of C#.Net Interview Questions(5)

Boxing and UnBoxing of C#.Net Interview Questions(5)




1.Define Boxing?
A)It is a process of converting value type to reference type is known as boxing.
For E.G:
int a=100;
object o=(object)a;//Boxing

2.Define UnBoxing?
A) It is a process of converting reference type to value type is known as unboxing.
For E.G:
object o=100;
int i=(int)o;//Unboxing
object o=(object)a;//Boxing

3.How boxing process can be takenplace?
A)Boxing can be takenplace implicitly in the program.

4. How unboxing process can be takenplace?
A)UnBoxing can be takenplace explicitly in the program.


5.What is the process of boxing?
A)Boxing is used to store value types in the garbage-collected heap. Boxing is an implicit conversion of a value type to the type object or to any interface type implemented by this value type. Boxing a value type allocates an object instance on the heap and copies the value into the new object. Due to this boxing and unboxing can have performance impact.

Value and Reference Types of C#.Net Interview Questions(5)



Value and Reference Types of C#.Net Interview Questions(5)



1.What are the types of data types available in C#?
A).In C# we have two type of datatypes are there.They are:
1. Value Types
2. Reference Types
2. If you define a user defined data type by using the struct keyword, Is it a a value type or reference type?
A) Value Type
3. If you define a user defined data type by using the class keyword, Is it a a value type or reference type?
A)Reference type

4. Give  Some examples for value types?
A)All Predefined data types i.e Integer,bool,string,Enum,Struct etc…

5. Give examples for reference types?
A)Class,String,Delegate, Array, ArrayList,Interface etc…



Basic and Features of C#.Net Interview Questions(30)

Basic and Features of C#.Net Interview Questions(30)

1.What is C#.Net?
A)C#.Net(“#” pronounced as Sharp) is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .Net Framework.
           C#.Net is a most powerful programming language among all other programming languages in .Net Framework because C#.Net is a combination features of C++,VB 6.0 and Java and additional features.
2.What is the Genesis structure of C#.Net?
A) C# syntax is highly expressive, yet it is also simple and easy to learn. The curly-brace syntax of C# will be instantly recognizable to anyone familiar with C, C++ or Java. Developers who know any of these languages are typically able to begin to work productively in C# within a very short time. 

3.List the Powerful Features of C#.Net?
A)C# syntax simplifies many of the complexities of C++ and provides powerful features such as
                                 Ø  Nullable Value Types
                                 Ø  Enumerations
                                 Ø  Delegates
                                 Ø   Lambda Expressions and
                                 Ø  Direct memory access,
Some Features which are not found in Java. C# supports such an advanced features are
Ø   Generic Methods and Types, which provide increased type safety and performance,
Ø  Iterators, which enable implementers of collection classes to define custom iteration behaviors that are simple to use by client code.
Ø  Language-Integrated Query (LINQ) expressions make the strongly-typed query a first-class language construct.

4.C#.Net Belongs which type of language?
A)C#.Net is a high level programming language.

5.Is C#.Net Supports OOPS ?
A)Yes C#.Net supports object oriented programming language features.

6.C#.Net is a case Sensitive or Not a case Sensitive Programming Langauage?
A)C#.Net is a Case Sensitive Programming Language.

7.What are the features of OOPS that supported by C#.Net?
A) As an object-oriented language, C# supports the concepts of
               Ø  Encapsulation
               Ø  Inheritance, and
               Ø  Polymorphism. 

8.What are the comments in C#.Net?
A) 1. Single Line Comments. You define single line comments with // as shown below.
//This is an example for single line comment
2. Multi line comments. You define multi line comments with /* */ as shown below.
/*This is an example for Multi Line comments*/
3. XML Comments. You define XML comments with /// as shown below.
///This is an example for defining XML comments.

9.Brief about .Net Framework  Platform Architecture?
A) C# programs run on the .NET Framework, an integral component of Windows that includes a virtual execution system called the common language runtime (CLR) and a unified set of class libraries. The CLR is the commercial implementation by Microsoft of the common language infrastructure (CLI), an international standard that is the basis for creating execution and development environments in which languages and libraries work together seamlessly.
Source code written in C# is compiled into an intermediate language (IL) that conforms to the CLI specification. The IL code and resources, such as bitmaps and strings, are stored on disk in an executable file called an assembly, typically with an extension of .exe or .dll. An assembly contains a manifest that provides information about the assembly's types, version, culture, and security requirements.

When the C# program is executed, the assembly is loaded into the CLR, which might take various actions based on the information in the manifest. Then, if the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions. The CLR also provides other services related to automatic garbage collection, exception handling, and resource management. Code that is executed by the CLR is sometimes referred to as "managed code," in contrast to "unmanaged code" which is compiled into native machine language that targets a specific system. The following diagram illustrates the compile-time and run-time relationships of C# source code files, the .NET Framework class libraries, assemblies, and the CLR.

F.G:fr1.png
Language interoperability is a key feature of the .NET Framework. Because the IL code produced by the C# compiler conforms to the Common Type Specification (CTS), IL code generated from C# can interact with code that was generated from the .NET versions of Visual Basic, Visual C++, or any of more than 20 other CTS-compliant languages. A single assembly may contain multiple modules written in different .NET languages, and the types can reference each other just as if they were written in the same language.

In addition to the run time services, the .NET Framework also includes an extensive library of over 4000 classes organized into namespaces that provide a wide variety of useful functionality for everything from file input and output to string manipulation to XML parsing, to Windows Forms controls. The typical C# application uses the .NET Framework class library extensively to handle common "plumbing" chores.

10.What are the types of applications that can be created using C#.Net?
A) You can use C# to create
                  Ø  Console Applications
                  Ø  Traditional Windows client applications
                  Ø  XML Web services
                  Ø  Distributed components
                  Ø  Client-server applications
                  Ø  Database applications, and much, much more.
Visual C# provides an advanced code editor, convenient user interface designers, integrated debugger, and many other tools to make it easier to develop applications based on version 4.0 of the C# language and version 4.0 of the .NET Framework.

11.What is Console Applications?
A) Visual C# Express Edition development environment as you build the simplest form of C# program, a console application.Console Applications are similar to c,c++ programs.In  Console Applications we completely work in CUI(Command User Interface)based environment.
              Because console applications perform all their input and output at the command line, they are ideal for quickly trying out language features and writing command-line utilities.
12.What is the purpose of “Using” Keyword?
A)”Using” is a keyword is used to include any namespace on the top of the program.
             E.G:Using System.Text;

13.Define Solution explorer?
A)Solution explorer is a virtual webdirectory for our program presented at right side of our visual studio environment.It is similar to windows explorer in windows.Usin solution explorer we can do following activities.They are:
                            Ø  Create Files/Folders
                            Ø  Delete Files/Folders
                            Ø  Rename Files/Folders
                            Ø  Copy Files/Folders
                            Ø  Move Files/Folders
With in the same solution.

14.What is Console Class?
A) Console is a Class used to work with Input and output streams. Console class is present in “System” namespace.

15.What are the functions with console class?
A)Console consists  of many functions.Some of them are listed below.They are:
                              Ø  Beep(int,int)
                              Ø  Write(“Message”)
                              Ø  WriteLine(“Message”)
                              Ø  Read()
                              Ø  ReadLine()
                              Ø  ReadKey()
                              Ø  Clear()
For More Info Refer:

16.What is the purpose of Beep(int,int) method?
A)Beep(int,int) method is used to produce a beep sound it accepts two integer parameters.

17.What is Write(“Message”)?
A)  Write(“Message”) is used to display any message to the user in the output stream.After displaying the message blinking cursor remains in the same line.
E.G:Console.Write(“I Welcomes  U”);
O/P:I Welcomes U_
18.What is WriteLine(“Message”)?
A)  WriteLine(“Message”) is used to display any message to the user in the output stream.After displaying the message blinking cursor in the next line.
E.G:Console.Write(“I Welcomes  U”);
O/P:I Welcomes U
       _

19.How can you relate Console.Write(“Message”) and Console.WriteLine(“Message”)?
A)Console.WriteLine(“Message”)=Console.Write(“Message\n”)

20.What is Read()?
A)This method is used to read a single character from the input stream.

21.What is ReadLine()?
A)This method is used to read a group of characters from the input stream.

22.What is Clear()?
A)This method is used to clears the contents of screen and is same as clrscr() in c.
23.What is the difference between Console.Read() and Console.ReadLine()?
A)
SNo
Read()
ReadLine()
1
Read Single/Next Character from the input stream
Read group of Character from the input stream
2
Reads maximum of only 1 characters
Reads maximum of 255 characters(Depends on OperatingSystem refWindows)
3
Reads Ascii Value of the character
Reads string value of the characters
4
Return type is integer
Return type is string

24.What is the use of main() function in C#.Net?
A)main() function is an entry point of an application.Main() method is of public acess specifier by default including with static type.

25.Can we set the specifier of the main() method in C#.Net as private?
A)Yes.When the access specifier is set as private for the Main() method then other assemblies may not invoke this class.Startup scope gets limited to the class in context itself.

26. Can we set different types of parameters and  return-types in main() method?
A)Yes. The Main() method may easily be played around with by developers by passing different parameters and setting different return types. See the code below, that demonstrates different ways the Main() method may be implemented:
C# Example
(1)public static void Main(string[] args)<br />
{//NO return type, the argument is an array of strings
}
 (2) public static int Main(string[] args)<br />
{
//Return type is int, argument is an array of strings
}
(3) public static int Main()
{
//Return type is int, NO arguments
}
(4) public static void Main()
{
//Return type is void, NO arguments
}

27.What is Command Line Arguments?
A) Command Line Arguments are used to pass an array of values to a main() method with an indexing value 
of arrays as a[0],a[1] etc…

28. What is the use of GetCommandLineArgs() method?
A) The GetCommandLineArgs() method is used to access the command line arguments. The return value of this method is an array of strings. See the code example below:
C# Example:

public static int Main(string[] args)
{
string[] strArgs = System.Environment.GetCommandLineArgs();
Console.WriteLine("Arguments {0}", strArgs[0]);
}

29.What is the purpose of System.Environment Class?
A. The class System.Environment is used to retrieve information about the operating system.
Some of the static members of this class are as follows:
1) Environment.OSVersion - Gets the version of the operating system
2) Environment.GetLogicalDrives() - method that returns the drives
3) Environment.Version - returns the .NET version running the application
4) Environment.MachineName - Gets name of the current machine
5) Environment.Newline - Gets the newline symbol for the environment
6) Environment.ProcessorCount - returns number of processors on current machine
7) Environment.SystemDirectory - returns complete path to the System Directory
8) Environment.UserName - returns name of the entity that invoked  the application

30.What is a variable?
A)variable holds of  information as per the user requirement.Variable can be declared as per the user input value.
Syntax:Datatype variablename
E.G:int a;