You are on page 1of 22

What is C# (C-Sharp)? C# is a new language created by Microsoft and submitted to the ECMA for standardization.

According Microsoft "C# is a modern, object-oriented language that enables programmers to quickly build a wide range of applications for the new Microsoft .Net platform, which provides tools and services that fully exploit both computing and communications."

What are the characteristics of C#? C# is designed for both computing and communication is characterized by several key features. It is 1. 2. 3. 4. 5. 6. 7. 8. 9. Flexible Interoprable Versionable Compatible and Simple Consitent Modern Object-oriented Type-safe

What is BOXING and UNBOXING in C#? BOXING in C# is the conversion of a VALUE type on stack to a OBJECT type on the heap. Viceversa the conversion from an OBJECT type back to a VALUE type is known as UNBOXING and it requires type casting.

In how many ways you can create new copies of an existing string in C#? There are two ways: 1. Using overloaded = operator like string s2 = s1;

2. Using the static Copy method like - string s2 = string.Copy(s1);

In how many ways you can compare two strings in C# using overloaded methods and operators?

GE Confidential

There are three ways: 1.OverloadedCompare()method 2.OverloadedEqual()method 3. Overloaded == operator. By default the member of the interface are public and abstract. true or false? True

Which collection class uses the unique key for the collection? HashTable

What is Process? Anything under execution.

What is thread? It is a process which executes independently.

Can interface have static member? Yes or No? No. Can constructers have access specifier ? Yes or No? Yes

How do I launch Internet Explorer in C#? using the statement System.Diagnostics.Process.Start("IExplore.exe",http://www.faqpanel.com);

How to concatenate two ArrayLists? System.Collections.ArrayList listA = new System.Collections.ArrayList(); System.Collections.ArrayList listB = new System.Collections.ArrayList(); listA.Add("1"); listA.Add("2"); listB.Add("3");

GE Confidential

listB.Add("4"); listA.AddRange(listB);

Is it possible to have a static indexer in C#? No, they are not allowed in C#.

What is type safety? Type safety is about increasing the opportunities for the compiler to detect your coding errors. If you use interfaces instead of delegates the compiler will have more opportunities to detect your coding errors. What is Namespace? Namespace provides a way of organizing related calsses and other types. Unlike the files or a component, a namespace is a logical rather than physical grouping. When you define a calss in C# file, you can include it within a namespace definition.

What are partial classes? The partial keyword allows the class, struct, or interface to span across multiple files. Typically in C# a class will reside entirely in a single file. However in situations where multiple developers need acees to the same class, or more likely in the situation where a code generator of some type generating part of the class, then having a class in multiple files can be beneficial. The way the partial keyword is used is to simply place partial before the calss, struct, or interface.

What is the static class? If a class contains nothing but static methods and properties, the class itself become static. A static class is functionally the same as creating a class with a private static constructor. An instance of the class can never be created. By using the static keyword, the compiler can help by checking that instance members are never accedentally added to the class. If they are added, the compiler error will happens. This can help guarantee that an instance is never created. The syntax for static class looks like this

GE Confidential

static { public { }} static

class void

StaticUtilities HelperMethod();

An object of type StaticUtilities not needed to call the HelperMethod(). The type name is used to make the call: StaticUtilities.HelperMethod();

Are constructors inherited in C#? No, constructors are not inherited.

What is the difference between Convert.ToInt32(string) and Int32.Parse(string)? The two give identical results, except where the string is null. Convert.ToInt32(null) returns zero, whereas Int32.Parse(null) throws an ArgumentNullException. What is the "is" operator? The "is" operator allows you to check whether an object is compatible with a specific type. For int if(i { Console.WriteLine("i } int, like all C# data types, inherits from object class; therefore the expresion "i is object" evaluates to true. is an object"); example to check i is whether a variable = object) is compatible with 10; object type -

Note: The phrase "is compatible" means that an object is either of that type or is derived from that type.
What is the "as" operator? The "as" operator is used to perform explicit type conversion of reference type. If the type being converted is compatible with specified type, conversion is performed successfully. However if the types are incompatible the "as" operator returns the value null. object o1 = "some string";

GE Confidential

object o2 = 5; string s1 = o1 as string; // s1 = "some string"

string s2 = o2 as string; // s2 = null

What is the "sizeof" operator? You can determine the size (in bytes) required on the stack by a value type using the "sizeof" operator unsafe { Console.WriteLine(sizeof(int)); } It will return the number 4, as an int is four bytes long in C#.

Note: You can only use "sizeof" operator in unsafe code.


How do you inherit from a class in C#? Place a colon and then the name of the base class. Notice that its double colon in C++.

Does C# support multiple inheritance? No, use interfaces instead. Are private class-level variables inherited? Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

Whats the data provider name to connect to Access database? Microsoft.Access.

What does the parameter Initial Catalog define inside Connection String? The database name to connect to.

When you inherit a protected class-level variable, who is it available to? Classes in the same namespace.

GE Confidential

What is the difference between the Debug class and Trace class? Documentation Use Debug looks class for the debug same. builds,

use Trace class for both debug and release builds. What is the difference between // comments, /* */ comments and /// comments? Single-line comments, multi-line comments, and XML documentation comments.

What namespaces are necessary to create a localized application? System.Globalization and System.Resources.

How is method overriding different from method overloading? When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.

What does the keyword virtual declare for a method or property? The method or property can be overridden.

Can you inherit multiple interfaces? Yes. Can multiple catch blocks be executed? No. Once the proper catch code fires off, the control is transferred to the finally block (if there is any), and then whatever follows the finally block.

Will the finally block get executed if an exception has not occurred? Yes.

What class is underneath the SortedList class? A sorted HashTable.

How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.

GE Confidential

What

is

the

difference

between

the

System.Array.CopyTo()

and

System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow. What is the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time it is being operated on, a new instance is created.

What is the size (in bytes) of C#.Net object? Each instance of a reference type has two fields maintained by the runtime - a method table pointer and a sync block. These are 4 bytes each on a 32-bit system, making a total of 8 bytes per object overhead. Obviously the instance data for the type must be added to this to get the overall size of the object. So, for example, instances of the following class are 12 bytes each: class { ... private } However, note that with the current implementation of the CLR there seems to be a minimum object size of 12 bytes, even for classes with no data (e.g. System.Object). Values types have no equivalent overhead. int x; MyInt

What are Identifiers? Identifiers are the names given to classes, methods, variables and interfaces. It must be a whole word and starts with either an alphabet or an underscore. They are case sensitive. The main point you should bear in mind is that the names should not clash with C# keywords. Some programmers use @ prefix as a first character while declaring identifiers to avoid clash with a keyword but it is not a recommended practice. Following names are valid identifiers in C# 1. 2. 3. 4. HelloYOu Hello hello H_ello

GE Confidential

What are the Keywords in C#? Keywords are special words built into the C# language and are reserved for specific use. This means you cannot use them for naming your classes, methods and variables. For instance, if you attempt to use a C# keyword (if) as your class name, the C# compiler will emit runtime error.

Can I use MySQL with C#? Yes, you can use MySQL with C#. You can connect to the database by using ODBC driver and the System.Data.Odbc namespace. Can I use DirectX in C#? Yes, you can.

Is it possible to have a static indexer in C#? No, static indexer are not allowed in C#.

Can I use inline assembly or IL in C# code? No, You cannot.

Does C# support jagged arrays? In both the C and C++ languages, each subarray of a particular multi-dimensional array must have identical dimensions. In other words, arrays must be orthogonal. However, in both the Java and C# languages, arrays need not be orthogonal; because, arrays are constructed as arrays of arrays. In C#, each array is one-dimensional. Therefore, jagged arrays of varying sizes can be built. The contents of a jagged array is arrays of instances or of references to arrays. Therefore, the rows and columns of a jagged array need not be of uniform length. The following C# example illustrates how to construct a jagged array: int anArray anArray [][]anArray [0] [1] = = = new new new int[3][]; int[7]; int[13];

anArray [2] = new int[5];

Does C# support variable method arguments?

GE Confidential

Yes. The params keyword can be applied to a method parameter which is an array. Upon method invocation, the array elements can be supplied as a comma (,) separated list. How do I do a case-insensitive string comparison? Use the String.Compare function. Its third parameter is a boolean which specifies whether case should be ignored or not. "fred" == "Fred" // false

System.String.Compare( "fred", "Fred", true ) == 0 // true For more control over the comparison, e.g. exotic features like width-sensitivity, consider using System.Globalization.CompareInfo.Compare(), CultureInfo.CurrentCulture.CompareInfo.Compare( "fred", CompareOptions.IgnoreCase CompareOptions.IgnoreKanaType CompareOptions.IgnoreWidth ); "Fred", | | e.g.

Does C# do array bounds checking? Yes. An IndexOutOfRange exception is used to signal an error.

Are C# constructors inherited No. C# constructors cannot be inherited. If constructor inheritance were allowed, then necessary initialization in a base class constructor might easily be omitted. This could cause serious problems which would be difficult to track down. For example, if a new version of a base class appears with a new constructor, your class would get a new constructor automatically. This could be catastrophic.

What happens in memory when you Box and Unbox a value-type? Boxing converts a value-type to a reference-type, thus storing the object on the heap. Unboxing converts a reference-type to a value-type, thus storing the value on the stack.

How do you convert a value-type to a reference-type? Use Boxing. How to make a C# destructor virtual? By definition, a C# destructor is virtual. Because, a C# destructor is basically an override of the Finalize method of System.Object. Therefore, there is no need to make a C# destructor

GE Confidential

virtual.

How can you sort the element of an aaray in descending order? By calling Sort() and then Reverse() Method of the array object.

Can multiple catch blocks be executed for a single try statement? No. Once the proper catch block processed, control is transferred to the finally block (if there is any).

What is the syntax to inherit from a class in C#? Place a colon and then the name of the base class. Example: class MyNewClass : MyBaseClass

Can you prevent your class from being inherited by another class? Yes. The keyword sealed will prevent the class from being inherited. What does the keyword virtual mean in the method definition? The method can be over-ridden.

Can you declare the override method static while the original method is non-static? No, you cannot, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

Can you override private virtual methods? No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.

Can you allow class to be inherited, but prevent the method from being over-ridden? Yes, just leave the class public and make the method sealed.

Can you inherit multiple interfaces? Yes, why not. How can you overload a method? Different data types of parameters, different number of parameters, different order of parameters.

GE Confidential

What is the difference between System.String and System.StringBuilder classes? System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

What is the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it is being operated on, a new instance is created.

Can you store multiple data types in System.Array? No.

What

is

the

difference

between

the

System.Array.CopyTo()

and

System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow. What is the datatype that allows the retrieval of data by a unique key? HashTable.

Differentiate the Lifetime with Scope. A variable maybe out of scope without having reached the end of its lifetime.

Define Scope. Scope refers to the region of code in which a variable may be accessed.

Define Lifetime. Lifetime refers to the span of time from when the variable is declared to when it is destroyed.

Why does C# compiler caught the use of = in place of == in if statement? C# treats Integer & Boolean data types as two entirely different types. List types of parameters that can be passed to a C# method. 1. 2. 3. 4. Parameter Arrays Value Reference Output Parameters Parameters Parameters

GE Confidential

What is the partial classes? The partial keyword allows the class, struct, or interface to span across multiple files. Typically a class resides entirely in a single file. However, in situations where multiple developers need access to the same class, or morelikely in the situation where a code generator of some type is generating part of a class, then having the class in multiple files can be beneficial. The way that the partial keyword is used is to simply place partial keyword before the class, struct, //BigClass1.cs partial { public } //BigClass2.cs partial { public } When the project that these two source files are part of is compiled, a single type called TheBigClass will be created with two methods. void method2(){ } class TheBigClass void method1(){ } class TheBigClass or interface. Eg.

What is the static class? If a class contains nothing but static methods and properties, the class itself can become static. A static class is functionally the same as creating a class with a private static constructor. An instance of the class can never be created. By using the static keyword, the compiler can help by checking that instance member are never accidentally added to the class. If they are, a compiler error happens. This can help guarantee that an instance is never created. The syntax for static public } An object of type StaticUtilities is not needed to call the HelperMethod(). The type name is used to make the call: static class static void class looks StaticUtilities HelperMethod(){ like { } :

GE Confidential

StaticUtilities.HelperMethod();

What is Shadowing in C#? Shadowing is a concept of polymorphism usage in Object Oriented Programming. This is a concept related to over-riding functions at run-time or making a shadow of the object methods in the inherited classes. Though it is not much used in programming but it may be used sometimes and its usage is very restrictive and unique.

What are Constructors? We know that all objects that are created on a class must be given initial values. This can be done individually. 2. Take the help of a function like GetData to initialize each object individually using statement like 3. : Using rect1.GetData(5, constructors. 8); in three ways 1. Using the dot operator to access the instance variables and then assigns values to them

Constructors are special type of methods, that enables an object to initialize itself when it is created. Constructors have the same name as the class itself. Secondly, they do not specyfy a return type, not even void. This because they do not return any value.

Constructors are usually public because they are provided to create objects. However they can also be declared as private or protected. What are Destructors? A destructor is opposite to s constructor. It is called when an object is no more required. The name of the destructor is the same as the class name and is preceded by a tilde(~) sign. Like constructors, a destructor has no return type. C# manages the memory dynamically and uses a garbage collector, running on a separate thread, to execute all destructors on exit. The process of calling a destructor when an object is reclaimed by the garbage collector is called finalization.

Note: Destructor takes no arguments.


How many Predefined Reference Types supported by C#? C# (Including supports two predefined Value reference Types) types : 1. object (System.Object) - The root type, from which all other types in the CTS derive 2. string (System.String) - Unicode character string.

GE Confidential

What is Strong Data Typing? One very important aspect of IL is that it is based on exceptionally Strong Data Typing. That means that all variables are clearly marked as being of a particular, specific data type (There is no room in IL, for example Variant data type recognized by Visual Basic and scripting languages). In particular, IL does not normally permit any operations that result in ambiguous data types.

What is refactoring? Developers develop their application first for functionality and then, they re-work their application to make them more manageable and more readable. This process is referred to as refactoring. Refactoring is the process of reworking code for more readability, performance, providing type safety, and lining application up to better adhere to OO programming practices.

What are Constants in C#? Prefixing a variable with the const keyword when it is declared and initialized designates that variable as a constant. As the name implies, a constant is a variable whose value cannot be changed during it lifetime: const int a = 501; // this value cannot be changed. constants never have be type following characteristics:

1. They must be initialized when they are declared, and once a value has been assigned, it can overwritten. 2. The value of the constant must be computable at the compile time. Therefore you cannot initialize a constant with a value taken from a variable. if need to do this, you will need to use read only fields. 3. Constant are always implicitly static, however, you don not have to include the static modifier in the constant declaration. What are Enumerations in C#? An Enumeration is a user defined integer type which provides a way for attaching names to numbers, thereby increasing the comprehensibility of the code. The enum keyword automatically enumerates a list of words by assigning them values 0,1,2 and so on. When you declare an enumeration, you specify a set of acceptable values that instance of that enumeration can contain. Not only that, but you can give the values user-friendly names. If, somewhere in your code, you attempt to assign a value that is not in the acceptable set of values to an instance of that enumeration, the compiler will flag an error. Eg. enum shape{

GE Confidential

Circle, Square, Triangle } this can be written in one line as follows:

enum shape { Circle, Square,Triangle }

What is the differences between Value Types and Reference Types: Value Type holds the data directly Reference Type points to the location that holds the data. Examples of value type variables: byte, decimal, float, int, structs

Examples of reference type variables: string, class, delegate, interface Value Type cannot contain null value

Reference Type can contain null value. Value Type variables are stored on stack.

Reference Type variables are stored on heap. A new type cannot be derived from value type.

A new type can be derived from reference type.

What is Application domine in C#.Net? Application doamin is a logical partition within which the process is isolated and hosts .Net assemblies inside it. The single process can have multiple application domains, and in turn each application domain has multiple threads inside it, but the thread not confined to the application domain as it is free to cross the app. domain boundries to another domain provided that the thread execution can be done only in a specific domain at a time. The application domain is managed and created by basically CLR.

What is difference between the System.Array.CopyTo() and System.Array.Clone()? The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither

GE Confidential

of these methods performs) would create a new instance of each elements object, resulting in a different, yet identacle object.

what is the difference between abstract class and interface in C#? An abstract class may contain complete or incomplete methods. Interfaces can contain only the signature of a method but no body. Thus an abstract class can implement methods but an interface can not implement methods. An abstract class can contain fields, constructors, or destructors and implement properties. An interface can not contain fields, constructors, or destructors and it has only the properties signature but no implementation. An abstract class cannot support multiple inheritance, but an interface can support multiple inheritance. Thus a class may inherit several interfaces but only one abstract class. A class implementing an interface has to implement all the methods of the interface, but the same is not required in the case of an abstract Class. Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in abstract Classes but not in interfaces What is the Abstract class (C#)? A class representing a base class which other types can subclass. A normal, non-abstract class is called a concrete class. An abstract class may contain either or both abstract and concrete methods. (Properties cannot be marked abstract.) As in ordinary inheritance, a type derived from an abstract class inherits all the base type members including any method implementations. But, if any abstract methods are inherited, the class must either declare itself abstract or provide an implementation. A C# abstract class is declared with the abstract keyword.

What is the Interface (C#)? Reference type containing only abstract membersdelegates, events, indexers, public methods, properties. The interface contains only member declarations. A class implementing an interface must provide the implementation of the interface members. An interface cannot contain constants, constructors, data fields, destructors, or static members. Interface member declarations are implicitly public. Classes or structs may inherit any number of interfaces. A C# interface is declared with the interface keyword

What is the Application domain (C#)? AppDomain is the logical and physical boundary created around every .Net application within the same application scopethe sequence of object activations starting from the application entry pointby the Common Language Runtime (CLR). The CLR can allow multiple .Net applications to be run in a single process by loading them into separate application domains. To make runtime behavior predictable, the CLR isolates each application domain from all other

GE Confidential

application domains and prevents the configuration, security, or stability of a running .NET applications from affecting other applications.

What is Delegate in C# ? Event handling mechanism of .Net. To raise events, a class must define one delegate per event type. To handle events, types must implement one event handler per event type. Delegates can reference both instance and static methods. C# uses the delegate keyword.

What is Event (winforms) ? Notification by an application or operating system that some event has occurred. An event is firedraisedwhen a predefined condition occurs, e.g., focus change in a GUI, interval timer, mouse click. An event handler is called in response to an event. The C# event model is publish and subscribe: Publishers create and publish events: Subscribers register to receive specifc events: Then, publishers send out their events only to subscribers. What are the Member variables (C#) ? Typed memory locations for storing values. Also known as a field or a local variable.

When do you absolutely have to declare a class as abstract? 1. When the class itseft is inherited from an abstract class, but not all base abstract methods have been overridden. 2. When at least one of the methods in the class is abstract.

What is delegate in C#? A delegate method encapsulate a reference to a method.

What is multicast delegate in C#? A delegate that has multiple handler assigned to it. Each assigned hander (Method) is called.

What OR

is

the

"this"

keyword

in

C#

What is the "this" reference in C# ? C# supports the keyword "this" which is a reference to the object that called the method. The "this" reference is available within all the member method and always refers to the current instance. It is normally used to distinguish between the local and instance variables that have the same name. The "this" reference is a hidden reference passed to every non-static method of a class. Consider the code -

GE Confidential

class int public this.x this.y =y; } } void

temp x, setXY(int x, =x; int y;

{ y) {

In the assignment statement, this.x and this.y refer to the class member named y and y whereas simple x and y refer to the parameter of the setXY() method. What is the static constructor in C#? If your class declares a static constructor, you are guaranteed that the static constructor will run before any instance of your class is created. Eg. public class Time { static Time () { Name = "Time"; } } Notice that there is no access modifier before the static constructor. Access modifiers are not allowed on static constructors. In addition, because this is a static member method, you can not access non-static variables and so Name must be declared a static member variable. private static string Name;

Note: You can not control exactly when a static constructor will run, but you do know that it will be after the start of your program and before the first instance is created, Because of this, you can not assume ( or determine ) whether an instance is being created.
What type of class cannot be inherited? A sealed class cannot be inherited. A sealed class is used primarily when the class contains static members. Note that a struct is implicitly sealed; so they cannot be inherited.

How do I use an alias for a namespace or class in C#? Use the using directive to create an alias for a long namespace or class. The using alias has a scope within the namespace you declare it in. // using // using list l = list new = list(); // act = Namespace: System.Runtime.Remoting.Activation; Class: System.Collections.ArrayList; Creates an ArrayList

act.UrlAttribute obj; // Equivalent to System.Runtime.Remoting.Activation.UrlAttribute obj

GE Confidential

What is inheritance? Inheritance is the mechanism which allows a class A to inherit properties of a class B. We say "A inherits from B". Objects of class A thus have access to attributes and methods of class B without the need to redefine them. If class A inherits from class B, then B is called superclass of A. A is called subclass of B. Objects of a subclass can be used where objects of the corresponding superclass are expected. This is due to the fact that objects of the subclass share the same behavior as objects of the superclass.

What is an Anonymous method in C#? Before C# 2.0, the only way to use delegates was to use named methods. In some cases, this results in forced creation of classes only for using with delegates. In some cases, these classes and methods are never even invoked directly. C# 2.0 offers an elegant solution for these methods described above. Anonymous methods allow declaration of inline methods without having to define a named method. This is very useful, especially in cases where the delegated function requires short and simple code. Anonymous methods can be used anywhere where a delegate type is expected. Anonymous Method declarations consist of the keyword delegate, an optional parameter list and a statement list enclosed in parenthesis. Code Snippet: Event Handler (without using anonymous methods) ... btnSave.Click ... void { SaveChanges(); lblStatus.Text } Code Snippet: Event Handler (using anonymous methods) btnSave.Click += delegate { SaveChanges(); lblStatus.Text = "Your changes have been saved"; }; Code Snippet: Event Handler using Anonymous Methods, with a parameter list = "Your changes have been saved"; AddClick(object sender, EventArgs e) += new EventHandler (btnSave_Click);

GE Confidential

btnSave.Click {

+=

delegate(object

sender,

EventArgs

e)

MessageBox.Show(((Button)sender).Text); SaveChanges(); MessageBox.Show("Your } changes have been saved");

Where should I use an Anonymous method? Anonymous methods can be used in the place where there is a use of a delegate. To understand anonymous methods we should understand the usage of delegate first.

Why should we use Anonymous method? We can reduce the code by preventing delegate instantiation and registering it with methods. It increases the readability and maintainability of our code by keeping the caller of the method and the method itself as close to one another as possible.

Why strings are called Immutable data Type? The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed. Thus keeping the old string in memory for garbage collector to be disposed.

How do assemblies find each other? By searching directory paths. There are several factors which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the applications directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.

What is GUID and why we need to use it and in what condition? How this is created? A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. Visual Studio .NET IDE has a utility under the tools menu to generate GUIDs. What is encapsulation? Encapsulation is the ability to hide the internal workings of an objects behaviour and its data. For instance, lets say you have a object named Bike and this object has a method named start(). When you create an instance of a Bike object and call its start() method you are not

GE Confidential

worried about what happens to accomplish this, you just want to make sure the state of the bike is changed to running afterwards. This kind of behaviour hiding is encapsulation and it makes programming much easier.

What are JIT compilers? How many are available in CLR? Just-In-Time compiler- it converts the language that you write in .Net into machine language that a computer can understand. There are two types of JITs one is memory optimized & other is performance optimized.

When do you use virtual keyword? When we need to override a method of the base class in the sub class, then we give the virtual keyword in the base class method. This makes the method in the base class to be overridable. Methods, properties, and indexers can be virtual, which means that their implementation can be overridden in derived classes.

Is it possible to use multiple inheritance in .Net? Multiple Inheritance is an ability to inherit from more than one base class i.e. ability of a class to have more than one super class, by inheriting from different sources and thus combine separately-defined behaviours in a single class. There are two types of multiple inheritance: multiple type/interface inheritance and multiple implementation inheritance. C# & VB.NET supports only multiple type/interface inheritance, i.e. you can derive a class/interface from multiple interfaces. There is no support for multiple implementation inheritance in .Net. That means a class can only derived from one class.

What are JIT compilers? How many are available in CLR? Just-In-Time compiler- it converts the language that you write in .Net into machine language that a computer can understand. There are two types of JITs one is memory optimized & other is performance optimized. What is metadata? Metadata is machine-readable information about a resource or "data about data. Such information might include details on content, format, size, or other characteristics of a data source. In .Net, metadata includes type definitions, version information, external assembly references, and other standardized information.

How many .Net languages can a single .Net DLL contain? One.

GE Confidential

Can you override private virtual methods? No. Private methods are not accessible outside the class.

What is the difference between string and String? No difference.

Can you write a class without specifying namespace? Which namespace does it belong to by default? Yes, you can, and then the class belongs to global namespace which has no name. For commercial products, naturally, you would not want global namespace. Explain the 3 types of properties in C# (c-sharp)? 1. Read Only Properties: Properties without a set accessor are considered read-only. 2. Write Only Properties: Properties without a get accessor are considered write-only. 3. Read Write Properties: Properties with both a get and set accessor are considered readwrite properties.

What are the advantages of properties in C# (c-sharp)? 1. from Properties some can other validate source data before such as allowing a a change. database. 2. Properties can transparently expose data on a class where that data is actually retrieved 3. Properties can take an action when data is changed, such as raising an event or changing the value of other fields.

Are private class-level variables inherited? Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

GE Confidential

You might also like