RealTime .net interview questions- Morgan stanley

Morgan Stanley interview questions with answer:

Technology : C#, .Net, OOPS, Multi-threading, Design Pattern

This post contains the realtime interview questions based on csharp. This is the first round interview questions for .net developer.

Q1. What is delegates and events.

Ans: Delegates in simple term can be referred as function pointers- data structure which holds the references of functions like a normal variable. We can assign one or more function’s references to the delegates, Such delegates are termed as multicast delegates. Using delegating, we can also invoke all the referenced functions just by invoking the delegating.

Q2. Why do we use delegate.

Ans: This one is the obvious questions, why do we need delegates to hold the function’s references, we can directly call the method, right?

Actually, the actual use of delegate is to add the ability of callbacks. Using delegate we can achieve callbacks.

Callbacks help us to bind the member function of one class to another class. Means, We can define a method to one class and can attach it to another class objects which uses the method. This way, It gives consumer class to write their own logic for the events they like.

For Example, Suppose we have Button class and consumer class is Window class, So Button class has the delegate/Event declared like ButtonClick. Now, window class can write their own logic for button click events like ButtonClick_Handler(). In Window class, we can attach the ButtonClick_Handler() to ButtonClick delegate/Event. So, Whenever user click a button, control will come to window class’s method to execute, that is, Callbac

Q3. If we have delegated then what is need of events.

Ans: Events is of type of delegates. You can relate it to the properties. Actually, Delegate has some features that makes it more error prone like :

– You can assign null to delegate

If you have assigned 2 methods to delegate and then assign null to it, all the previous 2 methods will be lost.

– You can assign method’s reference using = operator.

If you assigned 2 method’s using += operator and then you assigned 3 method using = operator, all the previous method’s reference will be lost.

So, Events helps for these scenario, You can not assign null to events and only +=, -= operator can be used. It helps delegates to formalize the pub-sub patterns and make it robust.

Q4. if you have delegate with below signature public int arithmatic(int, int)
and you assign 4 method to it which is add, sub, mul, div and execute the delegate what will be the output.

Ans: It will save the result of last method invoke in order.

Q5. object lifecycle in .net – memory mapping, data types and garbage collection.

Ans: Please comments with email it to get the detailed answer.

6. managed code and unmanaged code.

Ans: Code which runs under the CLR boundary called managed code. Means, The code which is managed by CLR like variable creation, allocation and deallocation of variables etc.

Unmanaged code- Objects and variable which is not managed by CLR like Sys32 resources, DB resources etc.
Q7. Best practices to use garbage collector – IDisposable pattern.

Ans: Best way to use for memory management is to use IDisposable pattern which helps to any chance of memory leakage.
Q8. What is yield keyword, use of the yield keyword.

Ans: Used for Stateful iteration. comment for detailed anwer.
Q9. Thread vs task

Q10. Thread synchronization.

Q11. Async vs await.

Q12. how would you do the asynchronous processing without using Async and await?

Ans: Using ContinueWith().
Q13. What is linked list and operation?

Q14. Write a program for reversing linked list and print.

Q15. What is dictionary and why does the key values get hashed?

Q16. What is Factory pattern and which problem does it solved?

You can also see these real interview questions :

RealTime interview questions csharp .net – Betsol

.Net Interview Questions for Fresher/Experienced

Conclusion: 

Hope these question will help the candidate preparing for the interview in morgan stanley. Please do comment if anyone needs the answer for these questions.

admin

Software professional, Blogger, Tech enthusiast.