Skip to main content

Interview questions - full stack Developer(.net/auzre)

Below are best-practice answers to the common interview questions I listed earlier. These answers are designed to be concise, clear, and demonstrate your expertise.


.NET Questions

1. What is the difference between IEnumerable and IQueryable?

  • IEnumerable:

    • Works with in-memory collections (e.g., List, Array).

    • Executes queries on the client side (LINQ-to-Objects).

    • Suitable for small datasets.

  • IQueryable:

    • Works with remote data sources (e.g., databases).

    • Executes queries on the server side (LINQ-to-Entities).

    • Suitable for large datasets and optimized for performance.

  • Example:

    csharp
    Copy
    IEnumerable<Customer> customers = db.Customers.Where(c => c.Age > 30).ToList(); // Executes in memory
    IQueryable<Customer> customers = db.Customers.Where(c => c.Age > 30); // Executes on the database server

2. How does dependency injection work in ASP.NET Core?

  • Dependency Injection (DI) is a design pattern used to achieve Inversion of Control (IoC) between classes and their dependencies.

  • How it works:

    • Services are registered in the Startup.cs or Program.cs file using services.AddSingletonservices.AddScoped, or services.AddTransient.

    • The framework injects these services into controllers, views, or other services via constructor injection.

  • Example:

    csharp
    Copy
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<IMyService, MyService>(); // Register service
    }
    
    public class MyController : Controller
    {
        private readonly IMyService _myService;
        public MyController(IMyService myService) // Inject service
        {
            _myService = myService;
        }
    }

3. Explain the lifecycle of a .NET application.

  • Compilation:

    • Source code is compiled into Intermediate Language (IL) by the C# compiler.

  • Execution:

    • The Common Language Runtime (CLR) loads the IL code and compiles it into machine code using Just-In-Time (JIT) compilation.

  • Memory Management:

    • The Garbage Collector (GC) automatically manages memory allocation and deallocation.

  • Application Domains:

    • .NET applications run in isolated environments called application domains.


4. What is the difference between Task and Thread in C#?

  • Thread:

    • Represents an actual OS-level thread.

    • Resource-intensive and harder to manage.

  • Task:

    • Represents an asynchronous operation.

    • Uses the ThreadPool for efficient resource management.

    • Supports async/await for easier asynchronous programming.

  • Example:

    csharp
    Copy
    // Thread
    Thread thread = new Thread(() => DoWork());
    thread.Start();
    
    // Task
    Task.Run(() => DoWork());

5. How do you handle exceptions globally in ASP.NET Core?

  • Use middleware to handle exceptions globally.

  • Example:

    csharp
    Copy
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error"); // Global exception handler
        }
    }

Azure Questions

1. What is the difference between Azure App Service and Azure Functions?

  • Azure App Service:

    • Used for hosting web applications, APIs, and mobile backends.

    • Supports multiple languages and frameworks.

    • Ideal for long-running applications.

  • Azure Functions:

    • Serverless compute service for event-driven tasks.

    • Executes code in response to triggers (e.g., HTTP, timers, queues).

    • Ideal for short-lived, stateless functions.


2. How do you secure an Azure SQL Database?

  • Authentication:

    • Use Azure Active Directory (AAD) or SQL authentication.

  • Authorization:

    • Implement Role-Based Access Control (RBAC).

  • Encryption:

    • Enable Transparent Data Encryption (TDE) for data at rest.

    • Use SSL/TLS for data in transit.

  • Firewall Rules:

    • Restrict access to specific IP addresses or virtual networks.


3. Explain the difference between Azure Blob Storage and Azure Table Storage.

  • Azure Blob Storage:

    • Used for storing unstructured data like images, videos, and documents.

    • Supports tiered storage (Hot, Cool, Archive).

  • Azure Table Storage:

    • NoSQL key-value store for structured data.

    • Ideal for storing metadata or semi-structured data.


4. How do you implement CI/CD using Azure DevOps?

  • Steps:

    1. Create a repository in Azure DevOps.

    2. Define a build pipeline (e.g., using YAML) to compile and test the code.

    3. Define a release pipeline to deploy the application to Azure.

    4. Use triggers to automate the process (e.g., on code push).

  • Example:

    yaml
    Copy
    trigger:
      branches:
        include:
          - main
    
    pool:
      vmImage: 'windows-latest'
    
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: '6.x'
    - script: dotnet build --configuration Release
    - script: dotnet test

5. What is the purpose of Azure Active Directory (AAD)?

  • AAD is a cloud-based identity and access management service.

  • Key Features:

    • Single Sign-On (SSO) for applications.

    • Multi-Factor Authentication (MFA) for enhanced security.

    • Integration with on-premises Active Directory.


Full Stack Questions

1. How do you optimize the performance of a web application?

  • Frontend:

    • Minify and bundle CSS/JS files.

    • Use lazy loading for images and components.

  • Backend:

    • Optimize database queries and use caching (e.g., Redis).

    • Use asynchronous programming to avoid blocking threads.

  • Infrastructure:

    • Scale horizontally using load balancers.

    • Use Content Delivery Networks (CDNs) for static assets.


2. What are the differences between REST and GraphQL?

  • REST:

    • Uses fixed endpoints for resources.

    • Over-fetching or under-fetching of data can occur.

  • GraphQL:

    • Uses a single endpoint for all queries.

    • Clients can request only the data they need.


3. How do you handle state management in a frontend application?

  • Local State:

    • Use component state (e.g., React useState).

  • Global State:

    • Use state management libraries like Redux or Context API.

  • Server State:

    • Use libraries like React Query or SWR for caching and synchronization.


4. Explain the concept of microservices and when to use them.

  • Microservices:

    • Architectural style where applications are built as a collection of small, independent services.

  • When to Use:

    • For large, complex applications requiring scalability and flexibility.

    • When different teams work on different parts of the application.


5. How do you ensure security in a full stack application?

  • Authentication:

    • Use OAuth, JWT, or AAD for secure authentication.

  • Authorization:

    • Implement role-based access control (RBAC).

  • Data Protection:

    • Encrypt sensitive data at rest and in transit.

  • Input Validation:

    • Sanitize user inputs to prevent SQL injection and XSS attacks.

Comments

Popular posts from this blog

Azure key vault with .net framework 4.8

Azure Key Vault  With .Net Framework 4.8 I was asked to migrate asp.net MVC 5 web application to Azure and I were looking for the key vault integrations and access all the secrete out from there. Azure Key Vault Config Builder Configuration builders for ASP.NET  are new in .NET Framework >=4.7.1 and .NET Core >=2.0 and allow for pulling settings from one or many sources. Config builders support a number of different sources like user secrets, environment variables and Azure Key Vault and also you can create your own config builder, to pull in configuration from your own configuration management system. Here I am going to demo Key Vault integrations with Asp.net MVC(download .net framework 4.8). You will find that it's magical, without code, changes how your app can read secretes from the key vault. Just you have to do the few configurations in your web config file. Prerequisite: Following resource are required to run/complete this demo · ...

How to Make a Custom URL Shortener Using C# and .Net Core 3.1

C# and .Net Core 3.1:  Make a Custom URL Shortener Since a Random URL needs to be random and the intent is to generate short URLs that do not span more than 7 - 15 characters, the real thing is to make these short URLs random in real life too and not just a string that is used in the URLs Here is a simple clean approach to develop custom solutions Prerequisite:  Following are used in the demo.  VS CODE/VISUAL STUDIO 2019 or any Create one .Net Core Console Applications Install-Package Microsoft.AspNetCore -Version 2.2.0 Add a class file named ShortLink.cs and put this code: here we are creating two extension methods. public   static   class   ShortLink {      public   static   string   GetUrlChunk ( this   long   key ) =>            WebEncoders . Base64UrlEncode ( BitConverter . GetBytes ( key ));      public   static   long   GetK...

AWS FREE ASP.NET CORE (.NET 6.0) HOSTING WITH FREE SSL

  FREE ASP.NET CORE (.NET 6.0) Hosting on AWS (Amazon Web Services) Today I was able to host my asp.net 6.0  + ANGULAR 14 application  on AWS Free  Initial Setup of your AWS Account and your Computer Get ready with your asp.net core 3.1 /.net 6 application Install  "AWS toolkit for visual studio 2022" as  visual studio extensions :  it will be required to deploy smoothly from Visual Studio 2022 itself, your life will be easy. Let's finish the AWS account setup  Get signed up with: its free but it will be required a valid credit card or debit card, they will charge nothing for the free services for 1 year * https://portal.aws.amazon.com/billing/signup#/start/email AWS console  for services and offering http://console.aws.amazon.com/ Create a user in AWS Console:  IAM With the help of AWS Identity and Access Management (IAM), you can control who or what has access to the services and resources offered by AWS, centrally manage fine-grained...