Skip to main content

Senior Software Engineer - .NET, Kathmandu

First Round (Decemeber 2022)

-------------------------------

Brief:

There were 4 people in the interview squad in the both round and each were experitise in their fields.

  1. .NET related questions were asked by .NET Expert.
  2. SQL related questions were asked by Database Expert.
  3. Front End related questions were asked by Front End Expert.
  4. Cloud Computing related questions were asked by DevOps Expert.

First Round (December 2022)

A. Question related to Exceptions & disposable.

1) What is the purpose of exception?

2) How is exception handling done in .NET? 

3) What is the purpose of finally block?

4) What is the purpose of IDisposable interface? 

5) Why we need to dispose object manually if it is automatically done by the framework?

6) Managed resource vs unmanaged resource? Unmanaged code vs managed code?

B. Question related to LINQ or Lambada

1) what the purpose of LINQ or lambada? 

2) What is lambad expression? 

3) The method like First(), FirstOrDefault(), TakeWhile(), SkipWhile()?

4) IQuerable vs IEnumerable

C. Question related to static

1) what is the purpose of static class and why we should we use it?

2) What if we have only static cass not the other types of class?

D. .NET general questions

1) For vs ForEach? Details of foreach like why to use and how does it work?

2) Filters in web api?

foreach(var x in list)

x.id = 20;

3) types of constructors? private constructors?

4) Singleton? What are the way we can create the singleton? Alternative to lock while creating singleton?

5) Design patterns? SOLID Principles?

6) Lazy?

7) Virtual keyword?


E. SQL related questions

1) Joins? Types of joins? 

2) Third highest salary in table?

3) Function vs Stored Proc?


Second Round (After 2 weeks - December 2022)

1) Introduction.

2) Ref vs out?

3) Set vs List? Lets say, you are creating a playlist of songs and you need to remove or add items in the playlist. How you are going to accomplish that?

4) You have A as base class and B as a Child class. How you can make B class not inheritable to other class?

5) How to find whether the string contains a repeatable character? Write coode and also complexity?

6) Rate youself in the .NET out of 10?

7) Find the state with the maximum number of cities from the table using linq? Write coode and also complexity?

8) .Equals() vs == and when to use which one?

9) Overloading vs overriding? How can we override the method of the base class?

10) Extension methods


Find the questions and the answers below:

Question related to Exceptions & disposable.

1) What is the purpose of exception?

Ans: Exceptions are used in programming to handle exceptional or exceptional situations that may arise during the execution of a program. They provide a way for the program to handle errors or unexpected conditions in a controlled and predictable way.

There are several purposes for using exceptions in a program:

  • Error handling: Exceptions can be used to handle errors that occur during the execution of a program. This can include errors that are caused by user input, system errors, or other unforeseen circumstances.
  • Control flow: Exceptions can be used to change the control flow of a program. For example, if an error occurs, the program can throw an exception and the control flow will be transferred to the exception handler.
  • Separation of concerns: Exceptions can be used to separate error handling logic from the main code of a program. This can make the code easier to understand and maintain.
  • Debugging: Exceptions can provide valuable information for debugging a program. For example, the exception message can provide details about the error that occurred, which can help to identify the cause of the problem.
Overall, the main purpose of exceptions is to provide a mechanism for handling errors and exceptional situations in a controlled and predictable way, which can help to ensure the stability and reliability of a program.

2) How is exception handling done in .NET? 

Ans: In .NET, exception handling is done using the try, catch, and finally blocks.

The try block encloses the code that might throw an exception. If an exception is thrown, control is transferred to the catch block, which contains the exception handling code. The finally block is optional and contains code that should always be executed, regardless of whether an exception is thrown.

You can have multiple catch blocks to handle different types of exceptions, or you can use a single catch block to handle all exceptions. You can also nest multiple try blocks within each other, in which case the innermost try block will handle the exception first, followed by the next outer try block, and so on.

Overall, exception handling in .NET provides a flexible and powerful mechanism for handling errors and exceptional situations in your code.

3) What is the purpose of finally block?

Ans: The finally block is a block of code that is used in exception handling to specify code that should be executed regardless of whether an exception is thrown or not. It is typically used to release resources or perform other cleanup tasks.

4) What is the purpose of IDisposable interface? 

Ans: The IDisposable interface is used in .NET to indicate that an object can be disposed of. It defines a single method, Dispose, which can be called to release resources held by the object.

Objects that implement the IDisposable interface are often used to manage resources that are limited or expensive to acquire, such as database connections, file handles, or network sockets. When an object that implements IDisposable is no longer needed, it is important to dispose of it promptly to release these resources.

The using statement creates an instance of MyDisposableObject and automatically disposes of it when the using block is exited. This ensures that the object's Dispose method is called, which releases any resources held by the object.

5) finally vs IDisposable?

Ans: The finally block and the IDisposable interface are both useful tools for managing resources and performing cleanup tasks in .NET.

However, they serve different purposes and are used in different ways. The finally block is used in exception handling to specify code that should always be executed, while the IDisposable interface is used to indicate that an object can be disposed of and to provide a way to release its resources.

6) Why we need to dispose object manually if it is automatically done by the framework?

Ans: There are a few reasons why you might need to manually dispose of objects in some frameworks, even though the framework may automatically dispose of them in certain situations:

  • Performance: Manually disposing of objects can sometimes be more efficient than relying on the framework to dispose of them automatically. This is because the framework might not dispose of objects immediately, but rather wait until it is more convenient to do so. This can lead to the objects remaining in memory for longer than necessary, which can affect the performance of your application.
  • Resource management: Some objects, such as database connections or file handles, represent a limited resource that needs to be released as soon as it is no longer needed. Failing to dispose of these objects promptly can result in resource exhaustion, which can lead to errors or other problems.
  • Code clarity: Manually disposing of objects can make it easier to understand the intended lifecycle of an object and how it is being used. This can make it easier to maintain and troubleshoot the code.
In general, it is a good idea to dispose of objects that implement the IDisposable interface when you are finished using them, especially if they represent a limited resource or if you want to ensure that they are disposed of promptly. This can help to ensure that your application is efficient and easy to maintain.

7) Managed resource vs unmanaged resource?

Ans: In .NET, a managed resource is a resource that is managed by the .NET runtime, while an unmanaged resource is a resource that is not managed by the .NET runtime.

Managed resources are typically objects that are created and managed by the .NET runtime, such as objects in the .NET Framework class library. They are automatically garbage collected when they are no longer needed, which means that the .NET runtime takes care of releasing the resources they hold.

Unmanaged resources, on the other hand, are resources that are not managed by the .NET runtime, such as file handles, database connections, or network sockets. These resources need to be explicitly released when they are no longer needed, in order to avoid resource leaks or other problems.

To release unmanaged resources, you can use the IDisposable interface, which defines a Dispose method that can be called to release the resources held by an object. For example, you might use the IDisposable interface to release a database connection or close a file handle when you are finished using it.

Overall, managed resources are easier to work with than unmanaged resources, because they are automatically managed by the .NET runtime. However, unmanaged resources are often necessary when working with external systems or resources that are not managed by the .NET runtime. It is important to properly manage and release unmanaged resources to ensure the efficiency and stability of your .NET application.

8) Unmanaged code vs managed code?

Ans: In .NET, managed code is code that is executed by the .NET runtime and is therefore subject to the runtime's control. Managed code is written in a .NET programming language, such as C# or VB.NET, and is compiled into an intermediate language (IL) that is executed by the .NET runtime.

Managed code has several advantages over unmanaged code:

  • Memory management: The .NET runtime automatically manages the allocation and deallocation of memory for managed code. This means that you do not have to worry about manually allocating and freeing memory, which can reduce the risk of memory-related errors.
  • Type safety: The .NET runtime checks the type safety of managed code at runtime, which can help to prevent type-related errors.
  • Garbage collection: The .NET runtime includes a garbage collector that automatically reclaims the memory used by managed code when it is no longer needed. This can help to improve the efficiency of your application and reduce the risk of memory leaks.
Unmanaged code, on the other hand, is code that is not executed by the .NET runtime and is therefore not subject to the runtime's control. Unmanaged code is typically written in a low-level language, such as C or C++, and is compiled into native machine code that is executed directly by the operating system.

Unmanaged code has several advantages over managed code:
  • Performance: Unmanaged code can sometimes be faster than managed code, because it is not subject to the overhead of the .NET runtime.
  • Interoperability: Unmanaged code can be used to interact with native operating system APIs or other unmanaged libraries, which can be useful in certain scenarios.
Overall, the choice between managed and unmanaged code depends on the specific needs of your application. Managed code is generally easier to work with and is more suitable for applications that do not require the maximum possible performance, while unmanaged code is generally faster but more complex to work with and is more suitable for applications that require maximum performance or need to interact with native operating system APIs.

Question related to LINQ or Lambada

1) What the purpose of LINQ or lambada?

Ans: LINQ (Language Integrated Query) is a set of language features in .NET that allows you to write queries over data in a variety of formats, including arrays, lists, and databases. LINQ introduces a standard syntax for querying data that is similar to SQL, the language used to query databases.

Lambda expressions are a feature of LINQ that allow you to create anonymous functions, which are functions that do not have a name and are not bound to an identifier. Lambda expressions are often used in LINQ queries to specify the logic for filtering or transforming data.

The main purpose of LINQ and lambda expressions is to provide a convenient and expressive way to query and manipulate data in .NET. They allow you to write expressive and powerful queries over data, and make it easy to work with data in a variety of formats.

2) What is lambad expression?

3) The method like First(), FirstOrDefault(), TakeWhile(), SkipWhile()?

4) IQuerable vs IEnumerable vs IList?

Ans: IQuerable and IEnumerable are both used to represent a sequence of objects that can be enumerated, which means that they can be iterated over using a foreach loop or LINQ query. However, IQuerable is designed to be used with LINQ queries, while IEnumerable is designed to be used with foreach loops.

IQuerable extends IEnumerable and adds a single method, Provider, which returns an IQueryProvider object that can be used to execute LINQ queries. This allows LINQ queries to be executed on IQuerable objects, which can be useful for optimizing the performance of queries or for executing queries against a data source that does not implement IEnumerable.

Question related to static

1) What is the purpose of static class and why we should we use it?

Ans: Here are some reasons why you might use a static class:

  • To create a utility class: A static class can be a convenient way to group related utility methods or constants that are needed by other parts of the application.
  • To improve performance: Because static classes do not have instance members, they can be more efficient than non-static classes, because they do not have to store per-instance state.
  • To enforce a singleton pattern: Because a static class cannot be instantiated, it can be used to enforce a singleton pattern, where there is only one instance of the class.
  • To reduce clutter: Because static classes do not have instance members, they can help to reduce clutter in your code by eliminating the need to create instances of the class or store state.
Overall, the purpose of a static class is to provide a way to group related static members and to enforce a singleton pattern, if desired. They are useful for creating utility classes and for improving the performance

2) What if we have only static cass not the other types of class?

Ans: If you only have static classes in your application, it means that you do not have any classes that can be instantiated or that have instance members.

This can be useful in certain scenarios, such as when you want to create a utility library or when you want to group related static members. However, it is also possible to create classes that are not static and that have both static and instance members, depending on the needs of your application.

.NET general questions

1) For vs ForEach? Details of foreach like why to use and how does it work?

Ans: It's also worth noting that foreach is only available for collections that implement the IEnumerable interface, while for can be used with any type of collection or even with no collection at all.

2) Filters in web api?

Ans: In ASP.NET Web API, filters are attributes that you can apply to controllers or action methods to modify the way that the action is executed. There are several types of filters available, including action filters, authorization filters, exception filters, and result filters.

3) Whether the 'list' below contains the updated record or not?

foreach(var x in list)

x.id = 20;

2) types of constructors? private constructors?

3) Singleton? What are the way we can create the singleton? Alternative to lock while creating singleton?

4) Design patterns? SOLID Principles?


SQL related questions

1) Joins? Types of joins? 

2) Third highest salary in table?

3) Function vs Stored Proc?


Cloud Related Queries

I said I have no experience in this field.

------------------------------

Second Round with USA team(After 2 weeks - Decemeber 2022)

------------------------------

1) Introduction.

2) Ref vs out?

3) Set vs List? Lets say, you are creating a playlist of songs and you need to remove or add items in the playlist. How you are going to accoplish that?

4) You have A as base class and B as a Child class. How you can make B class not inheritable to other class?

5) How to find whether the string contains a repeatable character? Write coode and also complexity?

6) Rate youself in the .NET out of 10?

7) Find the state with the maximum number of cities from the table using linq? Write coode and also complexity?

8) .Equals() vs == and when to use which one?

9) Overloading vs overriding? How can we override the method of the base class?

10) Extension methods


Questions:

 → Fibonacci number → 1, 1, 2, 3, 5, 8, 13, 21,….first two Fibonacci numbers are
1  →
2 = 1 + 1,
3 = 2 + 1,
5 = 3 + 2, and so on

int IsFib(int n)
{
    int sum = 0;
    int first = 1;
    int second = 1;

    while(sum <= n){
        if(n==sum)
            return 1;

        sum = first + second;
        first = second;
        second = sum;
    }

return 0;
}

//2 = 1+1,
//3 = 1 + 2,
//5 = 2 + 3

IsFib(5);//1
IsFib(7);//0


x => x+1;

x => Add(x);

Add(int y){
    return y +1;
}

IList<string> strList = new List<string>() {
                                            "Three",
                                            "Four",
                                            "Five",
                                            "Hundred"  };

var result = strList.TakeWhile(s => s.Length > 4);

foreach(string str in result)
        Console.WriteLine(str);

        IList<string> strList = new List<string>() {null, "One", "Two", "Three", "Four", "Five" };
        Console.WriteLine("1st  Element in intList: {0}",
                                strList.FirstOrDefault(s => s.Contains("T")));
                                

                                var cars = ["Mercedes", "Tesla","Volvo"];
cars[0] = ""

"use strict"
function foo(){

myNum= 33;
console.log(myNum);
}

foo();


select count(*) as EmpCount, Project group by Project.

2 P1
2 P2
1 P3


select top 3 where e.salary < e.salary order by desc

Welcome Bijay!
  **************************************************************
Please write a method that returns a boolean value of whether not an input string has duplicate characters.
For example:
"JAVA" ---> TRUE (because 'A' is duplicated)
".NET" ---> FALSE (all letters unique)

  ***************************************************************
 
 
public bool Method(string str)
{
  int i = 0;
    foreach(var c in str) //JAVA
    {
      
    }
 
  return false;
}


JAVA => str



public class Address
{
    public string State { get; set; }
    public string City { get; set; }
}
var addresses = _addressRepo.GetAll();

addresses.Selectect(x => x.state).GroupBy(x => x.state);
//State => c1, c2
//state2 > c3, c4
 
addresses.

//Identify state with max number of cities

Comments

Popular posts from this blog

Useful video links with Questions and Answers(.NET, SQL/Database, Azure, DSA, Docker, GIT, AI)

A) AI What is artificial intelligence (AI)? B) .NET SOLID Principles In C# With Examples Design Patterns In C# .NET (2023)   Design Patterns   Software Architecture And Patterns Shiva Kumar - .NET (Youtube)   Multithreading and multitasking Multithreading and asynchronous programming and parallel programming in C# (Youtube)   C) SQL/Database SQL Query Interview Questions - SQL Server Database (Youtube)   ACID Properties Of Transaction In DBMS (Youtube) D) Azure   Modules in this learning path - MSDN Susanth Sutheesh (Youtube)   E) DSA   Strivers A2Z DSA Course/Sheet F) Docker   Docker - Everything You Need To Know G) GIT   Start with Git & GitHub in Visual Studio Misc https://www.youtube.com/watch?v=aaUInV445BY Salary Negotiation - 10 tips on how to negotiate a Higher Salary    

npm install on windows 7 python2 not found error and node-sass@3.13.1 error #317

Before I write all, I'd like to say that before the update everything worked well; while updating node from version 7.2.1 to version 9.4.0 and npm from version 5.5.1 to version 5.6.0 in Windows 7 (64-bit) using the installer (https://nodejs.org/en/download/) and installing globally gulp-cli version 2.0.0, as far as npm install starts from the JointsWP folder I get the following error: $ npm install npm WARN deprecated babel-preset-es2015@6.24.1: รฐ  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue > uws@0.14.5 install C:\Users\Bob\Dropbox\Development\vhosts\mongoose-project\vanilla\themes\JointsWP\node_modules\uws > node-gyp rebuild > build_log.txt 2>...