Monday, 29 April 2024

Abstract class

  Abstract classes are classes that cannot be instantiated where you cannot create objects. Abstract classes work on the OOPS concept of abstraction. Abstraction helps to extract essential details and hide the unessential ones.

Sealed class: Sealed classes are classes that cannot be inherited. Use the keyword sealed to restrict access to users to inherit that class.

What is a managed and unmanaged code?

Managed code lets you run the code on a managed CLR runtime environment in the .NET framework. 
Managed code runs on the managed runtime environment than the operating system itself. 
Benefits: Provides various services like a garbage collector, exception handling, etc. 

Unmanaged code is when the code doesn’t run on CLR, it is an unmanaged code that works outside the .NET framework. 
They don’t provide services of the high-level languages and therefore, run without them. Such an example is C++.

6. What is the difference between an abstract class and an interface?

Let’s dig into the differences between an abstract class and an interface:

  • Abstract classes are classes that cannot be instantiated ie. that cannot create an object. The interface is like an abstract class because all the methods inside the interface are abstract methods.
  • Surprisingly, abstract classes can have both abstract and non-abstract methods but all the methods of an interface are abstract methods.
  • Since abstract classes can have both abstract and non-abstract methods, we need to use the Abstract keyword to declare abstract methods. But in the interface, there is no such need.

An abstract class has constructors while an interface encompasses none. 

No comments:

Post a Comment

Car pooling app

 I'll create a car pooling app with real-time vehicle tracking, pickup/drop time estimates, and a list of onboard users. Since we don...