below is a list of 125 basic C # interview questions. These interview questions are simple and straightforward, covering the most basic concepts of C #, mostly related to object-oriented concepts. So if you're preparing a C # interview, I suggest you have to master these 125 basic C # interview questions to review your C # concept. So let's take a look at these 125 basic C # interview quiz lists.
1. What is C #?
C # (pronounced "C sharp") is a simple, unconventional, object-oriented, type-safe programming language. C and C + + programmers will soon be familiar with it. C # combines a high-productivity rapid application development (RAD) language.
2. What are the annotation types in C #?
There are three types of annotations in C #.
Single line (//)
MultiRow (/* */)
Page/xml Note (//).
3. C #. What are the namespaces used in net?
Namespaces are logical groupings of types.
Using System;
Using System.Collections.Generic;
Using System.Windows.Forms;
4. What are the features of C #?
C # has the following features:
Simple
Type safety
Flexible
Object oriented
Compatible
Persistence of
Interoperability
Different from the traditional
5. What are the different categories of inheritance?
Four types of inheritance in object-oriented programming:
Single inheritance: includes a base class and a derived class.
Multilayer inheritance (Hierarchical inheritance): includes a base class and derived classes that inherit from the same base class.
Multilevel inheritance (Multilevel inheritance): Includes classes derived from a derived class.
Multiple inheritance (multiple inheritance): Includes multiple base classes and one derived class.
6. What are the basic concepts of object-oriented programming?
It is necessary to understand some of the concepts that are widely used in object-oriented programming. They include:
Object
Class
Data abstraction and encapsulation
Inherited
Polymorphism
Dynamic binding
Information transfer.
7. Can you inherit multiple interfaces?
OK. Multiple interfaces may be inherited in C #.
8. What is inheritance?
Inheritance is a new class that derives from a class that already exists.
9. Define scope? Define scopes?
Scope refers to the area in the code where a variable can be accessed.
What is the difference between public, static, and void?
Public: The keyword public is an access modifier used to tell the C # compiler that the main (main) method can be called by anyone.
Static: The keyword static indicates that the main (main) method is a global method and is accessible without the need to wear a class instance. The compiler stores the address of the method as a pointcut and uses this information to start executing it before any object is created.
void: The keyword void is a type modifier that indicates that the main (main) method does not return any values.
What are the modifiers in C #?
Abstract
Sealed
Virtual
Const
Event
Extern
Override
Readonly
Static
New
What are the types of access modifiers in C #?
The access modifiers in C # are:
Public
Protect
Private
Internal
Internal protect
13. What are crates and unboxing?
Variable value types are implicitly converted to reference types that become boxed, such as integer-to-object type conversions.
The reference type variable is converted back to the value type as a unboxing.
14. What is the object?
An object is an instance of a class. object is created using the new operation. A class creates an object in memory that will contain information about the value and behavior (or method) of a particular object.
What types of arrays are in C #?
One-dimensional array (single-dimensional)
Multidimensional Arrays (Multidimensional)
A jagged array (jagged arrays).
16. What is the difference between an object and an instance?
An instance of a user-defined type is called an object. We can instantiate a lot of objects from one class.
An object is an instance of a class.
Define destructors? Define destructors?
Destructors are called when the class object goes out of scope or is explicitly deleted. Destructors, as the name implies, are used to destroy objects created by the constructor. Just as a constructor, a destructor is a class-member method, with the same method name and class name, just beginning with the wave number.
18. How do I use enumeration data types?
An enumeration type is another user-defined type that provides a way to concatenate names into numbers, which improves the understanding of the code. The enum keyword automatically enumerates a set of words, assigns them a value of 0,1,2, and so on.
19. Define a constructor function?
A constructor is a member method that is similar to its name. The constructor is called whenever an object of its associated class is created. It is called a constructor because it constructs the values of the data members of the class.
20. What is encapsulation?
Wrapping data and functions as a unit (called a class) is called encapsulation. Encapsulation contains and hides object information, such as internal data structures and code.
Does C # support multiple inheritance?
Not supported, it is impossible. Supports multilevel inheritance.
22. What is an enum?
Enum is used to define constants.
23. What is a data set?
A dataset (DataSet) is a memory representation of the data that is loaded from any data source.
What is the difference between the private and public keywords?
Private: The keyword private is the default access level and is the most restrictive of all other access levels. It gives the minimum permissions for a type or type member. A private member can be accessed only in the body of the class in which it is declared.
Public: The keyword public is the most liberal of all access levels, without any access restrictions. Access to public members can come not only from the outside, but also from within, and can freely access any member defined within the class or outside the body.
25. Define polymorphism?
Polymorphism means a name, a variety of forms. It allows us to define more than one method of the same name in a program. It allows us to overload operations so that such operations can behave differently for different instances.
26. What is a jagged array?
A jagged array is an array of elements that are arrays.
The dimensions and sizes of jagged array elements can vary.
Jagged arrays are sometimes referred to as "arrays of arrays."
27. What is an abstract base class?
An abstract class is a class that is designed to be used exclusively as a base class. Abstract classes have at least one pure virtual method.
28. What is the difference between a method override and a method overload?
When you override a method, you change the behavior of the methods in the derived class. Overloaded methods only involve another method of the same name in the class.
What is the difference between the ref and out parameters?
The arguments passed to the ref parameter must be initialized first. In contrast, for out parameters, it is not necessary to display initialization before arguments are passed to an out parameter.
How does the using statement in C # work?
A using statement is typically a resource that executes a statement and then releases the resource.
31. What is serialization?
Serialization (serialization) is the process of converting an object to a byte stream.
Deserialization (de-serialization) is the reverse process of creating an object from a byte stream.
Serialization/deserialization is often used to pass objects.
32. What is the difference between a structure and a class?
A struct is a value type and a class is a reference type.
Structs cannot have constructors and destructors.
A class can have constructors and destructors at the same time.
Structs do not support inheritance, and classes support inheritance.
33. What is the difference between a class and an interface?
A class is a logical representation of an object. It is the definition of a collection of data and related sub-procedures.
An interface (Interface) is also a class that contains methods that do not have any method body definitions. The class does not support multiple inheritance, but interfaces are supported.
34. What is a delegate?
A delegate is a type-safe implementation of an object-oriented function pointer, and is used in situations where many of the components need to be recalled to the component that uses it.
35. What is authentication and authorization?
Authentication is the process of identifying a user. Authentication is the identification/authentication of the user with a certificate (user name and password).
Authorization is performed after authentication. Authorization is the process of granting access based on these user identities.
Authorization allows users access to a specific resource.
36. What is a base class?
A class declaration can specify a base class by adding a colon and a base class name to the class name. Omitting the base class description is equivalent to deriving from the object class.
Can the "This" be used in static methods?
No, ' this ' cannot be used in a static method. Only static variables/methods can be used in static methods.
What is the difference between constants, ReadOnly, and static?
Constants: The value cannot be changed.
Read-only: The value is initialized only once in the constructor of the class.
Static: The value can be initialized once.
What types of statements are supported in C #?
Several different types of statements supported by C # are
Block statements
Statement statement
An expression statement
SELECT statement
Iteration statements
Jump statement
Exception Handling Statements
Check and no check
Lock statement
40. What is an interface class?
It is an abstract class, and all public abstract methods must be implemented in their inheriting classes.
41. What are value types and reference types?
Value types are stored in the stack.
For example: bool, Byte, chat, Decimal, double, enum, float, int, long, sbyte, short, strut, uint, ulong, ushort.
Reference types are stored in the managed heap.
For example: Class, Delegate, interface, object, String.
42. What is the difference between the keyword string and the System.String class?
The keyword string is an alias for the System.String class. So, System.String and the keyword string are the same, you can use any naming convention you like. The string class provides many methods for safely creating, manipulating, and comparing strings.
What are the two data types available in C #?
Value type
Reference type
44. What are the types of caches?
There are three types of caches:
Output Caching: Stores the answer information for an ASP.
Fragment cache (Fragment Caching): Caches/Stores only part of the page content (user control).
Data Caching: Caches objects in a programmatic way for performance.
45. What is the difference between a custom control and a user control?
Custom controls are compiled code (Dlls), easy to use, create difficulties, and can be placed in the toolbox. Drag the control to use.
Properties can be specified intuitively at design time. Can be used by multiple applications (if shared DLLs), even private can be copied to the Web application's Bin directory, add references and use. It is often used to provide common functionality for standalone consumer applications.
User controls and ASP's include files are easily created and cannot be placed in a box to drag and drop them. User controls are shared between individual application files.
46. What is a method?
A method is a member that is executed by an object or class to implement a calculation or operation. Static methods are accessed through the class. Instance methods are accessed through instances of the class.
47. What is a domain?
A domain is a variable that is related to an instance of a class or class.
48. What is an event?
An event is a member that enables a class or object to provide notification. An event declaration is like a domain declaration, except that the declaration contains the Event keyword and the type must be a delegate type.
49. What are the texts and their types?
The text is the value constant that the program assigns to the variable. Several types of text supported by C # are
Integers (integer literals)
Real (real literals)
Boolean value (Boolean literals)
Single-character (single character literals)
Strings (string literals)
Backslash (backslash character literals)
50. What is the difference between a value type and a reference type?
A value type is stored on the stack, and the value of one variable is assigned to another variable.
The reference type is stored on the managed heap and is an assignment between two reference variables.
What are the characteristics of C #?
C # is a simple and powerful programming language for writing enterprise-edition applications.
It is a hybrid of C + + and VB. It preserves many C + + features, such as statements, expressions, and operators, and combines the productivity of VB.
C # helps developers to easily build Web services that can access the Internet in any language, any platform.
C # helps developers complete development with less code, thus making fewer mistakes in the code.
C # introduces considerable improvements and innovations such as type safety, versioning, events, and garbage collection in these areas.
52. What is the type of error?
Syntax error (Syntax error)
Logical errors (logic error)
Run-Time errors (runtime error)
What is the difference between the break and the continue statement?
The break statement is used to terminate the current enclosing loop or the conditional statement in which it is located. We have used the break statement to jump out of the switch statement.
Continue statements are used to change the order of execution. As with the break statement, the continue statement stops the current iteration and returns control only to the top of the loop, as opposed to jumping out of the loop.
54. Define namespaces?
Namespaces are called containers, which are used to organize hierarchies. NET class.
55. What is a code group?
A code group is a set of packages that share a security context.
What is a sealed class in C #?
The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class for another class.
57. What is the difference between a static method and an instance method?
The method declared with the static modifier is a static method. Static methods do not operate on specific instances, and can only be accessed by static members.
A method that is not declared with the static modifier is an instance method. Instance methods operate on a specific instance and can be accessed by static and instance members. The instance on which the instance method is invoked can display access like this. It is wrong to call this in a static method.
What are the types of variables in C #?
The different types of variables in C # are:
static variable (variables)
Instance variable (instance variable)
Value parameter (parameters)
Reference parameters (reference parameters)
Array elements (array elements)
Output parameters (Parameters)
Locals (local variables)
59. What does the method overload mean?
Method overloading allows multiple methods in the same class to have the same name, as long as they have a unique signature. When you compile a call to an overloaded method, the compiler uses overload resolution to determine the method that is called specifically.
60. What are parameters?
Parameters are used to pass a value or a variable reference to a method. The parameters of the method get their actual values from the parameters specified when the method is called. There are four parameters: a value parameter, a reference parameter, an output parameter, and an array of parameters.
is C # An object-oriented language?
Yes, C # is an object-oriented language like traditional Java and C + +.
What is the difference between array and ArrayList?
Arrays are collections of the same type. The size of the array is fixed at the time it is declared. A linked list is similar to an array, but it has no fixed size.
What are the special operators in C #?
C # supports a special operator.
Is (relational operator)
As (relational operator)
typeof (Type operator)
sizeof (size operator, used to get the size of an unmanaged class)
New (object operator)
. dot (member access operator)
Checked (overflow check)
Unchecked? (Prevent overflow check)
What does the operator in C # mean?
An operator is a member that defines the connotation of applying a particular expression of an operation to a class instance. You can define three types of operators: A unary operator, a two-tuple operator, and a conversion operator. All operators must be declared as public and static.
65. What is type parameterization?
Type parameterization is a type that is parameterized on top of another value or type.
66. What are the characteristics of abstract classes?
Abstract classes cannot be powerful, and it is wrong to use the new operator on an abstract class.
Abstract classes allow, but do not necessarily include, abstract methods and portals.
Abstract classes cannot use the scaled modifier.
How to use the abstract keyword?
The modifier abstract is a keyword used for a class to indicate that the class itself cannot have an instance or object directly, and that it can only be a "base class" for other classes.
How do I use the goto statement?
The goto statement is still included in the C # language. This goto can be used to jump from inside a loop to the outside. However, it is not allowed to jump inside a loop from outside the loop.
69. What is the difference between a console application and a window application?
A console application that is designed to run in a command line that does not have a user interface.
A window application designed to be executed on the user's desktop through the user interface.
How do I use the return statement?
The return statement is related to a program (method or function). When the return statement is executed, the system gives control from the called Program to the calling program. The return statement is used for two purposes:
Immediately returns the caller of the currently executing code
Returns some value to the caller of the currently executing code.
What is the difference between array and LinkedList?
Arrays are simple numeric sequences that do not care about the position of each other's elements. The position between them is independent of each other. It is very easy to add, delete, or modify any array element. A linked list is a complex sequence of numbers relative to an array.
Does C # have a throws clause?
No, unlike java,c#, developers are not required to specify the exceptions that the method can throw.
Does C # support variable number of parameters?
Yes, use the params keyword. This parameter is specified as a parameter list for a specific type.
74. Can I override a private virtual method?
No, private methods cannot be accessed outside the class.
75. What is a multicast delegate?
Each delegate object maintains a reference to a separate method. However, it is possible for a delegate object to keep a reference to multiple methods and call them. Such a delegate object becomes a multicast delegate or a composite delegate.
76. What are the unique features of C #?
XML document.
77. Is it recommended to use exceptions in C #?
Yes, exceptions in the. NET Framework are recommended error handling mechanisms.
78. What does the break statement do in the switch statement?
The break statement ends the loop in which it is located. It also alters the process of program execution.
In a switch statement, the break statement is used at the end of a case statement. The break statement is mandatory in C #, avoiding the flow of a case statement to another case statement.
is C # object oriented? is C # object-oriented?
Yes, C # is an object-oriented language like traditional Java and C + +.
80. What is smart navigation?
The cursor position remains the same because the server-side validation and the page refresh cause the page to refresh.
What is the difference between a const and a readonly?
is to define a constant value. The const field can only be initialized when the domain is declared. The readonly field can be defined either at the time of declaration or in the constructor.
Is there a throws clause in C #?
No, unlike java,c# do not need (or even allow) developers to specify exceptions that methods can throw.
83. What are the different ways that methods can be overloaded?
Different parameter types, different number of parameters, different parameter order.
84. Does the event have a return value?
No, the event does not have a return type.
85. What is the event?
An event is an action that is performed based on another program method.
An event is a delegate type class member that is used by an object or class to notify events that other objects have occurred.
Events can be declared with the event keyword.
86. What is an identifier?
The identifier does not have him, it is used to uniquely identify the names of various entities in the program.
What are the different text types in C #?
Boolean values: True and False are Boolean types that map to true and false states, respectively.
Integer: The value used to write the type Int,uint,long and ulong.
Real number: Used to write values of type float, double, and decimal.
Character: Represents a single-character, usually consisting of quoted characters, such as ' a '.
String: C # supports two types of strings, a rule string and a literal string. A rule string consists of 0 or more characters enclosed in double quotes, such as "116110″." A literal string consists of a @ character followed by a double-quoted character, such as @ "Hello".
Null: Represents a null type.
88. What is Data encapsulation?
Data encapsulation, also known as data hiding, is the mechanism by which the implementation details of a class are kept hidden from the user. A user can perform a limited set of operations on a class that has hidden members only by executing a special function called a method.
89. Can I override a private virtual method?
No, private methods cannot be accessed outside the class.
90. What are the main differences between subroutines and functions?
The subroutine has no return value, and the function has.
What is the difference between C # and C + +?
C # does not support # include statements. It only uses a using statement.
In C #, class definitions do not use semicolons at the end.
C # does not support multiple inheritance.
The display transformation of data types is much more secure in C # than in C + +.
Switch in C # can also be used for string values.
The behavior of the array of command-line arguments is not the same in C # and C + +.
92. What are nested classes?
A nested class is a class in a class.
A nested class is any class that declares that it occurs in another class or interface.
93. Can I give static constructor parameters?
No, a static constructor can have no arguments.
94. C #, is a string a value type or a reference type?
A string is an object (reference type).
Does C # provide copy constructors?
No, C # does not provide a copy constructor.
96. Can a class or struct have more than one constructor?
Yes, a class or struct can have more than one constructor. Constructors can be overloaded in C #.
97. Can I create an instance of an interface?
No, you can not create an instance of an interface.
98. Can the interface contain fields?
No, the interface cannot contain fields.
99. Can a class have static constructors?
Yes, classes can have static constructors. A static constructor is automatically called immediately before any static fields are accessed, and is typically used to initialize static class members. It is called automatically before the first instance is created or any static member is referenced. The static constructor is called before the instance constructor. An example is shown below.
What is the main role of delegation in C #?
Delegates are primarily used to define callback methods.
101. What is the difference between projection (shadowing) and rewrite (overriding)?
Overrides simply redefine the implementation and the projection redefine the entire element.
Overriding derived classes can refer to the parent class element through the "ME" keyword, but you can access the parent class element through "MYBASE" in the projection.
102. Can an event be accessed with an access modifier?
Yes, you can use the access modifier in the event. You can use the Portected keyword with events to allow only inherited class access. You can use the private modifier event to be accessible only to the current class object.
103. Why do I have the virtual keyword in my code?
The virtual keyword in the code is used to define methods and properties that can be overridden in a derived class.
104. What are constructors and destructors?
Constructors and destructors are special methods.
Constructors and destructors are special methods for each class.
Each class has its own constructors and destructors, and is called automatically when a class instance is created or destroyed.
Every time you access a class, the constructor initializes all class members. Destructors destroy objects when they do not want to be needed again.
105. How do we suppress the Finalize method?
Gc. SuppressFinalize ().
106. C # supports variable number of parameters?
Yes, use the params keyword.
This parameter specifies a list of parameters for a specific type, for example, Int. For maximum flexibility, the type can be object.
The standard example of using this method is System.console.writeLine ().
107. Which method is used to start a thread?
Start.
108. What is a generic type?
Generics help us create flexible, strongly-typed collections.
Generics essentially separate logic from the data type to maintain better reusability, better maintainability, and so on.
109. What are the different kinds of polymorphism?
There are two types of polymorphism, which are:
Compile-time polymorphism
Run Time polymorphism
110. What is the difference between compile-time polymorphism and run-time polymorphism?
Compile-time polymorphism
Compile-time polymorphism is also known as method overloading.
Method overloading refers to two or more methods with the same name but with different signatures.
Run Time polymorphism
Run-time polymorphism is also known as method rewriting.
Method overrides refer to two or more methods with the same name, with the same method signature but corresponding to different implementations.
111. Which namespace makes multithreaded programming in XML feasible?
System.Threading.
112. Can I declare a static block in C #?
No, because C # does not support static blocks, but it supports static methods.
113. Can the method be declared as sealed (sealed)?
Methods cannot be declared as sealed in C #. But when we rewrite a method in a derived class, we can define the overridden method as sealed. With its sealed, we can avoid further rewriting of the method.
114. What commands are used in C # to implement attributes?
Use the get and set modifiers in C # to implement properties.
115. What is a static member?
is defined as a static member and can be called directly from the class level, rather than from the class instance.
What is the syntax for inheriting a class in C #?
When a class is derived from another class, the members of the base class become derived members.
Access modifiers used by members accessing the base class specify the access state of the base class members in the derived class.
The syntax for inheriting classes from another class in C # is as follows:
Class Mynewclass:mybaseclass
117. What is the basic difference between a while loop and a Do While loop in C #?
The while loop tests its condition at the beginning, which means that if the condition evaluates to true, the enclosing statement block executes 0 or more times. The Do While loop traverses the statement block at least once and then checks for the condition at the end.
118. What are the main differences between subroutines and functions?
The subroutine has no return value, and the function has.
119. What is a sealed class in C #?
The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class for another class.
120. What is the difference between classes and interfaces?
An abstract class can implement some of its members, but an interface cannot implement any of its members.
Interfaces cannot have fields, and abstract classes can have fields.
An interface can inherit only from another interface and cannot inherit an abstract class, whereas an abstract class can inherit another abstract class or another interface.
A class can inherit multiple interfaces at the same time, and a class cannot inherit multiple classes at the same time.
Members of an abstract class can define access modifiers and interface members cannot define access modifiers.
121. What is the difference between abstract and virtual methods?
An abstract method does not provide an implementation, and the derived class is forced to override the method (unless the derived class is also an abstract class), and the virtual method can be implemented and overridden in a derived class is optional. Therefore, virtual methods can implement and provide choices that are overridden by derived classes. Abstract methods cannot provide implementations and force derived classes to override the method.
122. What is a static method?
As long as the method does not attempt to access any instance data or other instance methods, it is possible to declare it as static.
123. What is the new modifier?
The new modifier hides the members of the base class. C # only supports the concealment of signatures.
124. What are the advantages of get and set properties in C #?
The Get property accessor is used to return the property value.
The set property accessor is used to set the new value.
What is the difference between a. Const and a readonly?
Const-declared fields cannot use the static modifier, whereas readonly can use the static modifier.
The const field can only be initialized at declaration time, and ReadOnly may be initialized at the declaration or in the constructor.
The value of the Const field is calculated at design time, and the value of ReadOnly is evaluated at run time.