Top 20 Q & A
https://www.dotnettricks.com/learn/aspnetcore/top-20-asp-net-core-interview-questions-and-answers
Top 60
https://www.qfles.com/interview-question/asp-net-core-interview-questions
Here I am posting the important questions whatever I have faced in my interviews. (Few of the contents & links have been taken from various blogs/articles.) Hope it will help you..
Yes, an abstract class can have a constructor.
In general, a class constructor is used to initialize fields. Along the same lines, an abstract class constructor is used to initialize fields of the abstract class.
An abstract class constructor can also be used to execute code that is relevant for every child class. This prevents duplicate code.
You can not create an instance of an abstract class, so what is the use of a constructor in an abstract class?
You can not create an instance of the abstract class, we can create instances of the classes that are derived from the abstract class.
So, when an instance of the derived class is created, the parent abstract class constructor is automatically called.
Note: Abstract class cant be directly instantiated, The abstract class constructors get executed thru a derived class. So, it is a good practice to use a protected modifier with an abstract class constructor,using public doesn't make sense.
Sr. No. | Comparison | .Net Framework | .Net Core 3.1 |
---|---|---|---|
1 | Cross Platforms | .Net framework runs only on windows | .Net core is cross-platform, it operates on Windows, Linux, and Mac operating systems |
2 | Performance | Slow | Better |
3 | Application supported | the .NET framework is for developing desktop applications, web applications, and web services, WPF, ASP.NET MVC | MVC core 3.x |
4 | WCF/ WPF/WWF | Yes | No |
5 | Desktop Based | WPF, Winforms. | Nothing for desktop |
6 | Packaging | Packaged as big framework | Delivered via modularity using Nuget |
7 | Microservice Support | No | Yes |
8 | CLI Tools | More IDE Based | Full CLI command supported |
9 | Mobile Compatibility | No direct support | with .Net standard compatible with Xamarin |
9 | Cloud | Runs only on windows | Yes |
In an abstract class, we can create the functionality and that needs to be implemented by the derived class. The interface allows us to define the functionality or functions but cannot implement that. The derived class extends the interface and implements those functions.
Abstract Class | Interface |
---|---|
Abstract classes are inherited. | Interfaces are Implemented. |
It is a half-defined parent class. | It is a contract. |
Share some common logic in child classes | Planning Abstraction. |
It contains both declaration and definition parts. | It contains only a declaration part. |
It contains both declaration and definition parts. | It contains only a declaration part. |
Multiple inheritance is not achieved by abstract class. | Multiple inheritance is achieved by interface. |
It contain constructor. | It does not contain constructor. |
It can contain static members. | It does not contain static members. |
It can contain different types of access modifiers like public, private, protected etc. | It only contains public access modifier because everything in the interface is public. |
The performance of an abstract class is fast. | The performance of interface is slow because it requires time to search actual method in the corresponding class. |
It is used to implement the core identity of class. | It is used to implement peripheral abilities of class. |
A class can only use one abstract class. | A class can use multiple interface. |
If many implementations are of the same kind and use common behavior, then it is superior to use abstract class. | If many implementations only share methods, then it is superior to use Interface. |
Abstract class can contain methods, fields, constants, etc. | Interface can only contain methods . |
It can be fully, partially or not implemented. | It should be fully implemented. |
Sr. No. | Key | Abstract Class | Interface |
---|---|---|---|
1 | Definition | In terms of standard definition, an Abstract class is, conceptually, a class that cannot be instantiated and is usually implemented as a class that has one or more pure virtual (abstract) functions. | On other hand an Interface is a description of what member functions must a class, which inherits this interface, implement. In other words, an interface describes behaviour of the class. |
2 | Implementation | As like of other general class design in C# Abstract class also have its own implementation along with its declaration. | On other hand an Interface can only have a signature, not the implementation. While its implementation is being provided by the class which implements it. |
3 | Inheritance | As per specification in C# a class can extends only one other class hence multiple inheritance is not achieved by abstract class. | On other hand in case of Interface a class can implements multiple interfaces and hence multiple inheritance is achieved by interface. |
4 | Constructor | Like other classes in C# for instantiation abstract class also have constructor which provide an instance of abstract class to access its non-static methods. | On other hand Interface do not have constructor so we can't instantiate an interface directly although its method could get accessed by creating instance of class which implementing it. |
5 | Modifiers | As abstract class is most like of other ordinary class in C# so it can contain different types of access modifiers like public, private, protected etc. | On other hand as Interface needs to be get implemented in order to provide its methods implementation by other class so can only contains public access modifier. |
6 | Performance | As abstract class have its method as well as their implementations also for its abstract methods implementation it have reference for its implementing class so performance is comparatively faster as compare to that of Interface. | On other hand the performance of interface is slow because it requires time to search actual method in the corresponding class. |
Asynchronous JavaScript and XML (AJAX) is a development technique used to create interactive web applications or rich internet applications. AJAX uses a number of existing technologies together, including: XHTML, CSS, JavaScript, Document Object Model, XML, XSLT, and the XMLHttpRequest object.
Improving the performance of an application hosted in Microsoft Azure involves a combination of optimizing your application code, leveraging...