What is meant by an Abstract Class?
BeginnerIt's a type of class whose objects can't be instantiated, and it's signified by the term ' abstract '. It consists of a methodology or a single approach.
Programming
C# language, CLR, ASP.NET and Entity Framework.
64 questions
It's a type of class whose objects can't be instantiated, and it's signified by the term ' abstract '. It consists of a methodology or a single approach.
In method overriding, the relevant method definition is replaced in the derived class, thereby changing the method's behavior. When it comes to method overloading, a method is created with the same name in the same class but with different signatures.
C# is a modern, object-oriented programming language developed by Microsoft. It runs on the .NET platform and is used to build web applications, desktop software, mobile apps, cloud services, games, and enterprise applications.
The main difference between an abstract class and an interface are listed below:
Abstract Class | Interface Used to declare properties, events, methods, and fields as well. | Fields cannot be declared using interfaces. Provides the partial implementation of functionalities that must be implemented by inheriting classes. | Used to declare the behavior of an implementing class. Different kinds of access modifiers like private, public, protected, etc. are supported. | Only public access modifier is supported. It can contain static members. | It does not contain static members. Multiple inheritances cannot be achieved. | Multiple inheritances are achieved.
Garbage collector frees the unused code objects in the memory. The memory heap is partitioned into 3 generations:
Generation 0: It holds short-lived objects. Generation 1: It stores medium-lived objects. Generation 2: This is for long-lived objects.
Collection of garbage refers to checking for objects in the generations of the managed heap that are no longer being used by the application. It also performs the necessary operations to reclaim their memory. The garbage collector must perform a collection in order to free some memory space.
During the garbage collection process:
The list of live objects is recognized. References are updated for the compacted objects. The memory space occupied by dead objects is recollected. The remaining objects are moved to an older segment.
System.GC.Collect() method is used to perform garbage collection in .NET.
EXE and DLLs are assembly executable modules.
EXE is an executable file that runs the application for which it is designed. An EXE is produced when we build an application. Therefore the assemblies are loaded directly when we run an EXE. However, an EXE cannot be shared with the other applications.
Dynamic Link Library (DLL) is a library that consists of code that needs to be hidden. The code is encapsulated inside this library. An application can consist of many DLLs which can be shared with the other programs and applications.
C# is a modern, object-oriented programming language used with the .NET platform. Its key features include:
Strong typing and type safety Object-oriented programming support Automatic memory management Cross-platform support with .NET Rich library support Exception handling Support for modern features like LINQ and async/await
These features make C# useful for building web, desktop, mobile, cloud, and enterprise applications.
Did You Know? C# ranks as the 5th most popular programming language globally with a TIOBE rating of 4.85%, placing it ahead of PHP, TypeScript, and Swift in worldwide developer adoption. (Source: TIOBE, TIOBE Programming Community Index )
Feature | Value Type | Reference Type Storage | Stack | Heap Stores | Actual data | Reference (address) Type Example | int, float, bool, struct | string, class, object Memory Efficiency | More efficient | Less efficient Copy Behavior | Creates a copy | Copies the reference
JIT, or "Just In Time," is a compiler that, at runtime, transforms the compiled intermediate code (CIL) into machine code so that it may execute on the hardware of the computer. This enhances performance. This enhances performance. JIT compiles methods just before they are executed when a .NET app runs.
Public declared variables can be accessed from anywhere in the application. Static variables can be accessed globally without creating an instance of the class. Void is a type modifier that states the method and is used to specify the return type of a method in C#.
An assembly is a file that is automatically generated by the compiler which consists of a collection of types and resources that are built to work together and form a logical unit of functionality. We can also say, assembly is a compiled code and logical unit of code.
Assemblies are implemented in the form of executable (.exe) or dynamic link library (.dll) files.
Four steps of code compilation in C# include -
Source code compilation in managed code. Newly created code is clubbed with assembly code. The Common Language Runtime (CLR) is loaded. Assembly execution is done through CLR.
When a restriction needs to be placed on the class that needs to be inherited, sealed classes are created. In order to prevent any derivation from a class, a sealed modifier is used. A compile-time error occurs when a sealed class is forcefully specified as a base class.
There is no difference between int and Int32. Int32 is a type provided by the .NET framework class whereas int is an alias name for Int32 in the C# programming language.
An object is an instance of a class. It represents a real value created from the class blueprint and contains its own data through fields or properties. Objects are used to access the methods and members defined in a class. In C#, an object is usually created using the new keyword.
Continue statement - Used in jumping over a particular iteration and getting into the next iteration of the loop.
Break statement - Used to skip the next statements of the current iteration and come out of the loop.
Boxing is the process of converting a value type into a reference type directly. Boxing is implicit.
Unboxing is the process where reference type is converted back into a value type. Unboxing is explicit.
An example is given below to demonstrate boxing and unboxing operations:
int a = 10; // a value type object o = a; // boxing int b = (int)o; // unboxing
The main difference between managed and unmanaged code is listed below:
Managed Code | Unmanaged Code It is managed by CLR. | It is not managed by CLR. .NET framework is a must for execution. | Does not require a .NET framework for the execution. Memory management is done through garbage collection. | Runtime environment takes care of memory management.
Serialization converts an object into a format (like JSON, XML, or binary) for storage or sending, while deserialization converts that data back into an object.
A constructor is a member function with the same name as its class. The constructor is automatically invoked when an object is created. While the class is being initialized, it constructs all the values of data members.