Class A has [Serializable()] attribute. When is [Serializable] checked?
Anonymous Quiz
29%
At C# compile time
41%
At CLR runtime
19%
At JIT compile time
11%
At Linking
❓Discuss the difference between constants and read-only variables
While constants and read-only variable share many similarities, there are some important differences:
- Constants are evaluated at the compile-time, while the read-only variables are evaluated at the runtime.
- Constants support only value-type variables, while read-only variables can hold reference type variables.
- Constants should be used when the value is not changing during the runtime, and read-only variables are used mostly when their actual value is unknown before the runtime.
While constants and read-only variable share many similarities, there are some important differences:
- Constants are evaluated at the compile-time, while the read-only variables are evaluated at the runtime.
- Constants support only value-type variables, while read-only variables can hold reference type variables.
- Constants should be used when the value is not changing during the runtime, and read-only variables are used mostly when their actual value is unknown before the runtime.
The followings are some examples of integer arrays. Which expression is not valid in C#?
Anonymous Quiz
5%
int[] a = new int[10];
7%
int[][] c = new int[10][];
43%
int[][][] cc = new int[10][2][];
6%
int[,] b = new int[10, 2];
39%
int[, , ,] d = new int[10, 2, 2, 2];
Which of the following statements is true about C# anonymous type?
Anonymous Quiz
22%
Anonymous type can add new property once it is created
6%
Anonymous type can add an event
27%
You can use a delegate for a method in anonymous type
45%
Anonymous type is an immutable type
❓Explain the difference between managed and unmanaged code
MANAGED CODE is a code created by the .NET compiler. It does not depend on the architecture of the target machine because it is executed by the CLR (Common Language Runtime), and not by the operating system itself. CLR and managed code offers developers few benefits, like garbage collection, type checking and exceptions handling.
On the other hand, UMANAGED CODE is directly compiled to native machine code and depends on the architecture of the target machine. It is executed directly by the operating system. In the unmanaged code, the developer has to make sure he is dealing with memory usage and allocation (especially because of memory leaks), type safety and exceptions manually. In .NET, Visual Basic and C# compiler creates managed code. To get unmanaged code, the application has to be written in C or C++.
MANAGED CODE is a code created by the .NET compiler. It does not depend on the architecture of the target machine because it is executed by the CLR (Common Language Runtime), and not by the operating system itself. CLR and managed code offers developers few benefits, like garbage collection, type checking and exceptions handling.
On the other hand, UMANAGED CODE is directly compiled to native machine code and depends on the architecture of the target machine. It is executed directly by the operating system. In the unmanaged code, the developer has to make sure he is dealing with memory usage and allocation (especially because of memory leaks), type safety and exceptions manually. In .NET, Visual Basic and C# compiler creates managed code. To get unmanaged code, the application has to be written in C or C++.
📝 What is the difference between dispose and finalize methods in C#?
Finalizer and Dispose both are used for same task like to free unmanaged resources but have some differences see.
Finalize:
🔸 Finalize used to free unmanaged resources those are not in use like files, database connections in application domain and more, held by an object before that object is destroyed.
🔸 In the Internal process it is called by Garbage Collector and can't called manual by user code or any service.
🔸 Finalize belongs to System.Object class.
🔸 Implement it when you have unmanaged resources in your code, and make sure that these resources are freed when the Garbage collection happens.
Dispose:
🔸 Dispose is also used to free unmanaged resources those are not in use like files, database connections in Application domain at any time.
🔸 Dispose explicitly it is called by manual user code.
🔸 If we need to dispose method so must implement that class by IDisposable interface.
Finalizer and Dispose both are used for same task like to free unmanaged resources but have some differences see.
Finalize:
🔸 Finalize used to free unmanaged resources those are not in use like files, database connections in application domain and more, held by an object before that object is destroyed.
🔸 In the Internal process it is called by Garbage Collector and can't called manual by user code or any service.
🔸 Finalize belongs to System.Object class.
🔸 Implement it when you have unmanaged resources in your code, and make sure that these resources are freed when the Garbage collection happens.
Dispose:
🔸 Dispose is also used to free unmanaged resources those are not in use like files, database connections in Application domain at any time.
🔸 Dispose explicitly it is called by manual user code.
🔸 If we need to dispose method so must implement that class by IDisposable interface.
What is the result of variable a and b?
Anonymous Quiz
22%
a=true, b=true
34%
a=true, b=false
19%
a=false, b=true
26%
a=false, b=false
❓What are the fundamental concepts of OOP?
OOP stands for Object-Oriented Programming and the following are the fundamental concepts:
- Encapsulation: It is the internal representation of an object which is hidden from the outside view of an object’s definition. Only required information is accessed while the other data are hidden.
- Abstraction: It is defined as the process of identifying critical behavior, eliminating the irrelevant details and data of an object.
- Inheritance: It is defined as the process of creating new classes from another class. This can be achieved by accessing, modifying, and extending the behavior of the objects in their parent class.
- Polymorphism: It is a term used for describing one name in many forms. It can be achieved through the same name but different implementations.
https://youtu.be/m_MQYyJpIjg
OOP stands for Object-Oriented Programming and the following are the fundamental concepts:
- Encapsulation: It is the internal representation of an object which is hidden from the outside view of an object’s definition. Only required information is accessed while the other data are hidden.
- Abstraction: It is defined as the process of identifying critical behavior, eliminating the irrelevant details and data of an object.
- Inheritance: It is defined as the process of creating new classes from another class. This can be achieved by accessing, modifying, and extending the behavior of the objects in their parent class.
- Polymorphism: It is a term used for describing one name in many forms. It can be achieved through the same name but different implementations.
https://youtu.be/m_MQYyJpIjg
YouTube
Fundamental Concepts of Object Oriented Programming
This video reviews the fundamental concepts of Object Oriented Programming (OOP), namely:
Abstraction, which means to simplify reality and focus only on the data and processes that are relevant to the application being built; Encapsulation meaning that data…
Abstraction, which means to simplify reality and focus only on the data and processes that are relevant to the application being built; Encapsulation meaning that data…
📝 What is the difference between is and as operators in C#?
The is operator checks if an object can be cast to a specific type.
The is operator checks if an object can be cast to a specific type.
if (someObject is StringBuilder) ...The as operator attempts to cast an object to a specific type, and returns null if it fails.
StringBuilder b = someObject as StringBuilder;
if (b != null) ...
When defining a class using C# Generics, which of the followings is invalid?
Anonymous Quiz
29%
class MyClass where T : struct
6%
class MyClass where T : class
8%
class MyClass where T : IComparable
12%
class MyClass where T : MyBase
45%
All of the above are correct
❓State the difference between is and as operators in C#
The difference between is and as an operator in C# is that is the operator is used for checking the compatibility of an object for a given type and returning to the Boolean for the results.Whereas as the operator is used for casting of an object to a type or to a class.
https://youtu.be/IKmRtJcRX_I
The difference between is and as an operator in C# is that is the operator is used for checking the compatibility of an object for a given type and returning to the Boolean for the results.Whereas as the operator is used for casting of an object to a type or to a class.
https://youtu.be/IKmRtJcRX_I
YouTube
IS vs AS Keyword | C# Interview Questions with Answers | Csharp Interview Questions | IS vs AS in C#
See our other Step by Step video series below :-
For more such videos visit http://www.questpond.com
For more such videos subscribe https://www.youtube.com/questpondvideos
See our other Step by Step video series below :-
JavaScript Interview Questions: h…
For more such videos visit http://www.questpond.com
For more such videos subscribe https://www.youtube.com/questpondvideos
See our other Step by Step video series below :-
JavaScript Interview Questions: h…
📝 Can you create a function in C# which can accept varying number of arguments?
By using the params keyword, you can specify a method parameter that takes a variable number of arguments. No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration. The declared type of the params parameter must be a single-dimensional array.
By using the params keyword, you can specify a method parameter that takes a variable number of arguments. No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration. The declared type of the params parameter must be a single-dimensional array.
The following C# code is using C# Generics. Which is an incorrect explanation?
Anonymous Quiz
8%
If T is int type, variable t has 0
26%
If T is a reference type, variable t has null
58%
If T is string type, variable t has an empty string
8%
If T is bool type, variable t has false
❓State the difference between the “throw” and “throw ex” in .NET
The difference between “throw” and “throw ex” is that “throw” is used for preserving original error stack whereas “throw ex” has a throw point through which it can trace the stack. For more accurate, error-free information, the throw is advisable to use.
The difference between “throw” and “throw ex” is that “throw” is used for preserving original error stack whereas “throw ex” has a throw point through which it can trace the stack. For more accurate, error-free information, the throw is advisable to use.
📝 What is the best practice to have best performance using Lazy objects?
You typically use it when you want to instantiate something the first time its actually used. This delays the cost of creating it till if/when it's needed instead of always incurring the cost.
Usually this is preferable when the object may or may not be used and the cost of constructing it is non-trivial.
For example Lazy<T> makes implementing lazy, thread-safe singletons easy.
You typically use it when you want to instantiate something the first time its actually used. This delays the cost of creating it till if/when it's needed instead of always incurring the cost.
Usually this is preferable when the object may or may not be used and the cost of constructing it is non-trivial.
For example Lazy<T> makes implementing lazy, thread-safe singletons easy.
C# / .NET supports various built-in data structures. Which of the following data structures does not exist as built-in?
Anonymous Quiz
2%
Array
45%
D-Array
37%
Binary Tree
5%
Stack
11%
Linked List
❓What are the different types of serialization?
Following are the three different types of serialization:
- XML serialization: All the public properties are serialized to the XML document.
- SOAP: Any system that understands SOAP can use this serialization. System.Runtime.Serialization is the place where all the classes reside.
- Binary serialization: It is used for the conversion of any code into binary form.
Following are the three different types of serialization:
- XML serialization: All the public properties are serialized to the XML document.
- SOAP: Any system that understands SOAP can use this serialization. System.Runtime.Serialization is the place where all the classes reside.
- Binary serialization: It is used for the conversion of any code into binary form.