C# OOP interview question |C# tutorial |C# Advance interview question|C# Programing Interview question|Important C sharp Interview Questions
What is Programing?
Programming is to solve problems using computers.
How to do it at all? How to do it robustly? How to do it effectively?
Programming consists of two steps:
Algorithmic design (the architects)
Coding (the construction workers)
Programming requires: A programming language (e.g., C#) to express your ideas
A set of tools to design edit and debug your code A set of tools to design, edit, and debug your code A compiler to translate your programs into machine
code A machine to run the executable code
Why Programing?
Computer in becoming Ubiquitous …
programming gets you more out of the computer
learn how to solve problems
dealing with abstractions
be more precise
Unfortunately, Most People
know little about Computer Science and know little about Programming. Write bad or buggy programs
become lost when writing large programs
1)Algorithms and Data Structures?
Algorithm: a strategy for computing something, e.g.,
sorting: putting data in order by key
searching: finding data in some kind of index
finding primes and generating random numbers – finding primes and generating random numbers string processing
graphics: drawing lines, arcs, and other geometric objects. Algorithms use that organization
Data Structure :
A way to store data. e.g:-
1)Arrays and vectors
2) linked lists. Data structures organize data.
2)What is CLR [Common Language Runtime] ?
The common language runtime (CLR) is the engine that runs and “manages” executing code. Thus from a security perspective, the CLR enforces the .Net framework’s restrictions on executing code and restrictions on executing code and
prevents it from behaving unexpectedly. CLR works like a virtual machine in
executing all languages.
The CLR supports many different languages and targets on these features:
1)Compilation and Verification – Compilation and Verification
2)Security
3)Memory Management
3)What is MSIL and MetaData ?
MSIL is a CPU-independent set of instructions that can be efficiently converted to native code.
Metadata is information about the types defined in the managed code.
4)What is CLR-Memory Management ?
Garbage Collection: Every instance of a reference type is allocated on the heap. As the application runs, the
memory allotted to the heap fills up Before the memory allotted to the heap fills up. Before new instances can be created, more space must be made available.
The process of doing this is called garbage collection is called garbage collection
When CRL notices that the heap is full, it will automatically run the garbage collector
Garbage objects can appear anywhere in the heap.
Garbage collection can reposition the contents of the heap.
The garbage collection views objects in generations.
5)Differences Between Classess and Structs ?
| Classes | Structs |
| References types (objects are allocated on the heap) | value types (object are allocated on the stack) |
| support inheritance | no inheritance |
| All classes are derived from object | but they are compatible with the object |
| may declare a parameterless constructor | must not declare a parameterless constructor |
| can implement interface | can implement interface |
| may have a destructor | no destructor |
5)What is Boxing and Unboxing ?
Boxing: The assignment wraps up the value 3 in a heap object
object obj=3;
UnBoxing: The assignment int x=(int ) obj;
unwraps the value again.
6)What is generics ?
A generic collection is strongly typed (type-safe), meaning that you can only put one type of object into it.
This eliminates type mismatches at runtime.
Another benefit of type safety is that performance is better with value type objects because they don’t incur
the overhead of being converted to and from type object.
7)Different between Classes and Structs ?
A class can inherit from a single base class but can implement multiple interfaces.
A struct cannot inherit from any type but can implement multiple interfaces.
Every interface member (method, property, indexer) must be implemented or
inherited from a base class.
Implemented interface methods need not be declared as override Implemented interface methods need not be declared as an override.
Implemented interface methods can be declared as abstract(i.e. an interface
can be implemented by an abstract class)
8) What does the term immutable mean?
The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
9)What’s the top .NET class that everything is derived from?
Answer: System.Object.
10)Are private class-level variables inherited?
Answer: Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
11)Describe the accessibility modifier “protected internal”?
Answer: It is available to classes that are within the same assembly and derived from the specified base class.
12)What does the term immutable mean?
Answer: The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
13)What’s the difference between System.String and System.Text.StringBuilder classes?
Answer:
System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
14)Can you store multiple data types in System.Array?
Answer: No
15)How can you sort the elements of the array in descending order?
Answer: By calling Sort() and then Reverse() methods.
16) What’s the .NET collection class that allows an element to be accessed using a unique key?
Answer: HashTable.
17)What class is underneath the SortedList class?
Answer: A sorted HashTable.
18) Will the finally block get executed if an exception has not occurred?
Answer: Yes.
19) What’s the C# syntax to catch any possible exception?
Answer: A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
20)Can multiple catch blocks be executed for a single try statement?
Answer: No. Once the proper catch block is processed, control is transferred to the finally block (if there are any).
21) Explain the three services model commonly know as a three-tier application.
Answer:
- GUI Layer (graphical user interface )
- Business logic Layer
- Data base Layer
22)Does C# support multiple-inheritance?
Answer: No
Click here for Asp.net Question and answer
More related topic website link given below…
C# Interview Questions | c# interview questions 2022
Top 50 C# Interview Questions and Answers for Experienced

