Examness

Programming

.NET & C# の面接質問

C# language, CLR, ASP.NET and Entity Framework.

64 問

  1. 1.

    What is meant by an Abstract Class?

    初級

    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.

  2. 2.

    What is the difference between method overriding and method overloading?

    初級

    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.

  3. 3.

    What is C#?

    初級

    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.

  4. 4.

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

    初級

    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.

  5. 5.

    What is a garbage collector?

    初級

    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.

  6. 6.

    What is an EXE and a DLL?

    初級

    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.

  7. 7.

    Mention the features of C# briefly

    初級

    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 )

  8. 8.

    What are the differences between value and reference types in .NET?

    初級

    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

  9. 9.

    What is JIT?

    初級

    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.

  10. 10.

    What is the difference between static, public, and void?

    初級

    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#.

  11. 11.

    What is an assembly?

    初級

    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.

  12. 12.

    Explain the four steps involved in the C# code compilation

    初級

    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.

  13. 13.

    What are sealed classes in C#?

    初級

    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.

  14. 14.

    What is the difference between int and Int32?

    初級

    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.

  15. 15.

    What is an object?

    初級

    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.

  16. 16.

    Differentiate between Break and Continue Statements

    初級

    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.

  17. 17.

    What is boxing and unboxing in .NET?

    初級

    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

  18. 18.

    What is the difference between managed and unmanaged code?

    初級

    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.

  19. 19.

    What is serialization and deserialization in .NET?

    初級

    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.

  20. 20.

    Define Constructors

    初級

    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.