InterView Question
Type Script:
Note : need to assign value to variable var/let before use.other wise it will give compile time error
1. What is difference between Let and Var.
Var variable have globaly scope.
example:
var x:string="global";
{
var x:string="local";
}
console.log(x);
output: local
now var variable have latest assigned value (either local or global block).
Let variable have scope according to block.
let x:string="global";
{
var x:string="local";
}
console.log(x);
output: global
Note : need to assign value to variable var/let before use.other wise it will give compile time error
1. What is difference between Let and Var.
Var variable have globaly scope.
example:
var x:string="global";
{
var x:string="local";
}
console.log(x);
output: local
now var variable have latest assigned value (either local or global block).
Let variable have scope according to block.
let x:string="global";
{
var x:string="local";
}
console.log(x);
output: global
- Now let variable 's local block's value does not change the global value but in var variable 's local block's value is change the global value.
- We can not redeclare the let varibale again in same block but var can be declare many times.
- the let variable will not be added to the global window object.
- if let is decalre inside a block , we can not acces outside that block. it will give undefined compile time error. but var can used outside.
- in case of let in forloop can not outside the for loop but var can be used.
Array :
var arr = ["r"]; //javascript type
var arr1: string[] = ["xw", "d", "d"];
var arr2: Array<string>;
arr2=["e"]
console.log(arr1[0]);
arr1 = [];
console.log(arr1);// whole array show
console.log(arr1[0]); //after array null undefined print
var arr2: Array<string|number>; //union for multiple data type
Tuple :
Tuple is a new data type which includes two set of values of
different data types.
// Tuple type variable
var employee: [number, string] = [1, "Steve"];
C# throw vs throw ex
throw : If we use "throw" statement, it preserve original error stack information. In exception handling "throw" with empty parameter is also called re-throwing the last exception.
throw ex : If we use "throw ex" statement, stack trace of exception will be replaced with a stack trace starting at the re-throw point. It is used to intentionally hide stack trace information.
throw ex : If we use "throw ex" statement, stack trace of exception will be replaced with a stack trace starting at the re-throw point. It is used to intentionally hide stack trace information.
Interview Questions
- Q1: Why do we use MSMQ?
- Microsoft Message Queuing, or MSMQ, is technology for asynchronous messaging. Whenever there's need for two or more applications (processes) to send messages to each other without having to immediately know results, MSMQ can be used. MSMQ can communicate between remote machines, even over Internet.
Q2: What is .NET Standard?- .Net Standard is a specification which dictates what the Base Class Libraries of different .Net platforms should implement to unify the Base Class Libraries of different .Net Platforms. Here, Platform means full .NetFramework, .Net Core, Xamarin, Silverlight, XBox etc. This also enables code sharing between applications that runs on these different platforms. For example, a library or a component that is developed on top of a platform that implements specific .Net Standard version can be shared by all the applications that runs on any of the platforms that implements same .Net Standard version.
Q3: Explain the difference between Task and Thread in .NET- https://www.dotnetforall.com/difference-task-and-thread/
- Task : NET framework provides Threading.Tasks class to let you create tasks and run them asynchronously. A task is an object that represents some work that should be done. The task can tell you if the work is completed and if the operation returns a result, the task gives you the result.
- It can be used whenever you want to execute something in parallel. Asynchronous implementation is easy in a task, using’ async’ and ‘await’ keywords.
- Thread : NET Framework has thread-associated classes in System.Threading namespace. A Thread is a small set of executable instructions.
When the time comes when the application is required to perform few tasks at the same time.
- Task is more abstract then threads. It is always advised to use tasks instead of thread as it is created on the thread pool which has already system created threads to improve the performance.
- Task is are generally created on the thread pool which are treated as background threads while thread is by default not background
- Thread does not retun result.
- No continuation in thread.
- We cannot cancel a thread while it is in middle of the operation
- One of the major difference between task and thread is the propagation of exception. While using thread if we get the exception in the long running method it is not possible to catch the exception in the parent function but the same can be easily caught if we are using tasks.
Q4: What do you know about Azure WebJobs?- WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app, API app, or mobile app. There is no additional cost to use WebJobs.
Q5: What is difference between constants and readonly?- The difference is that a readonly member can be initialized at runtime, in a constructor, as well being able to be initialized as they are declared. A const is a compile-time constant whereas readonly allows a value to be calculated at run-time and set in the constructor or field initializer.
Q6: Refactor the code- Refactoring is the process of changing the code structure after we complete the writing of the code to increase readability and easy maintenance of the code. Refactoring is done by changing the internal structure of the code without changing the external behavior of the code block. ReSharper Tool
Q7: What is lambda expressions in C#?- Lambda expressions are anonymous functions that contain expressions or sequence of operators. All lambda expressions use the lambda operator =>, that can be read as “goes to” or “becomes”. The left side of the lambda operator specifies the input parameters and the right side holds an expression or a code block that works with the entry parameters.
Q8: What is Facade pattern?- Facade in C# Facade is a structural design pattern that provides a simplified (but limited) interface to a complex system of classes, library or framework. While Facade decreases the overall complexity of the application, it also helps to move unwanted dependencies to one place
Q9: Define what is Let clause?- It projects a new range variable, allows re-use of the expression and makes the query more readable.Let keyword use with a variable that can store the result of the sub-expression in order to reuse it in the upcoming clause.
- Q10: Explain the Single Responsibility Principle?
Q11: What is Indexer in C#?
Q12: What is the "yield" keyword used for in C#?
Q13: Name some advantages of LINQ over Stored Procedures
Q14: What is GOD class and why should we avoid it?
Q15: When would you use Duplex WCF service?
Q16: Explain Finalize vs Dispose usage?
Q17: What is difference between WCF and Web API and WCF REST and Web Service?
Q18: Can you create sealed abstract class in C#?
Q19: Implement the "Where" method in C#
Q20: What's the difference between the Dependency Injection and Service Locator patterns?
OOP stands for object-oriented programming. In an interview, a good answer to this question would point out that OOP languages such as Visual Basic.NET, C#, and C++ are the core languages supported by .NET Framework. (There is also support for functional programming in the form of F#.) As a technique, OOP allows .NET developers to create classes containing methods, properties, fields, events and other logical modules. It also lets developers create modular programs, which they can assemble as applications. OOPs, have four basic features: encapsulation, abstraction, polymorphism, and inheritance.
What is the difference between a class and an object, and how do these terms relate to each other? Show Less
Comments
Post a Comment