Interview question for programming in C#.
Bacics of C#
1-What is C#?
C# (pronounced "C sharp") is a simple, modern, object-oriented, and type-safe programming language.
It will immediately be familiar to C and C++ programmers.
2. Is C# is object oriented?
YEs, C# is an OO langauge in the tradition of Java and C++.
3. What are the characteristics of C#?
There are several characteristics of C# are :
4. What are the features of c#?
C# is a simple and powerful programming language for writing enterprise edition applications.
This is a hybrid of C++ and VB. It retains many C++ features in the area statements,expressions, and operators and incorporated the productivity of VB.
C# helps the developers to easily build the web services that can be used across the Internet through any language, on any platform.
C# helps the developers accomplishing with fewer lines of code that will lead to the fewer errors in the code.
C# introduces the considerable improvement and innovations in areas such as type safety,versioning. events and garbage collections.
5. How does C# differ from C++?
C# does not support #include statement. It uses only using statement.
In C# , class definition does not use a semicolon at the end.
C# does not support multiple code inheritance.
Casting in C# is much safer than in c++.
In C# switch can also be used on string values.
Command line parameters array behave differently in C# as compared to C++.
6- What are the types of comment in C#?
There are 3 types of comments in C#.
Single line (//)
Multi (/* */)
Page/XML Comments (///).
7. What is a data set?
A DataSet is an in memory representation of data loaded from any data source.
8. What are the different types of Caching?
There are three types of Caching :
Output Caching: stores the responses from an asp.net page.
Fragment Caching: Only caches/stores the portion of page (User Control)
Data Caching: is Programmatic way to Cache objects for performance.
9. How many classes can a single .NET DLL contain?
It can contain many classes.
Variables, Data Type, Type Conversion, Statement, Flow Control, Method
10. How big is the datatype int in .NET?
11. What are the two data types available in C#?
12. what are value types and reference types?
Value types are stored in the Stack.
Examples : bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort.
Reference types are stored in the Heap.
Examples : class, delegate, interface, object, string.
13. What is the difference between value type and reference type?
Value types are stored on the stack and when a value of a variable is assigned to another variable.
Reference types are stored on the heap, and when an assignment between two reference variables occurs.
14. What is literals and their types?
Literals are value constants assigned to variables in a program. C# supports several types of literals are
Single character literals
Backslash character literals
15. What are the different types of variables in C#?
Different types of variables used in C# are :
16. What are the different types of statements supported in C#?
C# supports several different kinds of statements are
Try catch statements
Checked and unchecked
17. What is parameters?
Parameters are used to pass values or variable references to methods. The parameters of a method get their actual values from the arguments that are
specified when the method is invoked. There are four kinds of parameters: value parameters, reference parameters, output parameters, and parameter arrays.
18. What is meant by operators in c#?
An operator is a member that defines the meaning of applying a particular expression operator to instances of a class. Three kinds of operators can be
defined: unary operators, binary operators, and conversion operators. All operators must be declared as public and static.
19. What are the special operators in C#?
C# supports the following special operators.
is (relational operator)
as (relational operator)
typeof (type operator)
sizeof (size operator)
new (object creator)
.dot (member access operator)
checked (overflow checking)
unchecked (prevention of overflow checking)
20. What is the use of enumerated data type?
An enumerated data type is another user defined type which provides a way for attaching names to numbers thereby increasing comprehensibility of the code.
The enum keyword automatically enumerates a list of words by assigning them values 0,1,2, and so on.
21. What is boxing and unboxing?
Implicit conversion of value type to reference type of a variable is known as BOXING, for example integer to object type conversion.
Conversion of reference type variable back to value type is called as UnBoxing.
22. What is the difference between break and continue statement?
The break statement is used to terminate the current enclosing loop or conditional statements in which it appears. We have already used the break statement
to come out of switch statements.
The continue statement is used to alter the sequence of execution. Instead of coming out of the loop like the break statement did, the continue statement stops
the current iteration and simply returns control back to the top of the loop.
23. What is the use of return statement?
The return statement is associated with procedures (methods or functions). On executing the return statement, the system passes the control from the called
procedure to the calling procedure. This return statement is used for two purposes :
to return immediately to the caller of the currently executed code
to return some value to the caller of the currently executed code.
24. What is the use of goto statement?
The goto statement is also included in the C# language. This goto can be used to jump from inside a loop to outside. But jumping from outside to inside a
loop is not allowed.
25. What is a parameterized type?
A parameterized type is a type that is parameterized over another value or type.
26. What is methods?
A method is a member that implements a computation or action that can be performed by an object or class. Static methods are accessed through the class.
Instance methods are accessed through instances of the class.
27. What is fields?
A field is a variable that is associated with a class or with an instance of a class.
28. What is the difference between static and instance methods?
A method declared with a static modifier is a static method. A static method does not operate on a specific instance and can only access static members.
A method declared without a static modifier is an instance method. An instance method operates on a specific instance and can access both static and instance
members. The instance on which an instance method was invoked can be explicitly accessed as this. It is an error to refer to this in a static method.
29. What is events?
An event is a member that enables a class or object to provide notifications. An event is declared like a field except that the declaration includes an
event keyword and the type must be a delegate type.
30. What is the difference between string keyword and System.String class?
String keyword is an alias for Syste.String class. Therefore, System.String and string keyword are the same, and you can use whichever naming convention
you prefer. The String class provides many methods for safely creating, manipulating, and comparing strings.
31. Where are the types of arrays in C#?
32. What is Jagged Arrays?
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.
33. Define namespace?
The namespace are known as containers which will be used to organize the hierarchical set of .Net classes.
34. What are the namespaces used in C#.NET?
Namespace is a logical grouping of class.
35. What is the use of using statement in C#?
The using statement is used to obtain a resource, execute a statement, and then dispose of that resource.