FilteredList()
1951 | {
1952 | foreach( object item in FullList )
1953 | {
1954 | if( IsItemInPartialList( item )
1955 | yield return item;
1956 | }
1957 | }
1958 | ```
1959 | Could you explain what does the `yield` keyword do there?
1960 |
1961 | **Answer:**
1962 | Read Full Answer on 👉 FullStack.Cafe
1963 |
1964 | #### Q11: Can you create sealed abstract class in C#? ⭐⭐⭐⭐⭐
1965 | **Answer:**
1966 | Read Full Answer on 👉 FullStack.Cafe
1967 |
1968 | #### Q12: Implement the "Where" method in C# ⭐⭐⭐⭐⭐
1969 | **Answer:**
1970 | Read Full Answer on 👉 FullStack.Cafe
1971 |
1972 | #### Q13: What is Facade pattern? ⭐⭐⭐
1973 | **Answer:**
1974 | **Facade pattern** hides the complexities of the system and provides an interface to the client using which the client can access the system. This type of design pattern comes under *structural pattern* as this pattern adds an interface to existing system to hide its complexities.
1975 |
1976 |
1977 |
1978 | This pattern involves a single class which provides simplified methods required by client and delegates calls to methods of existing system classes.
1979 |
1980 | **Source:** _tutorialspoint.com_
1981 |
1982 | #### Q14: What's the difference between the Dependency Injection and Service Locator patterns? ⭐⭐⭐⭐⭐
1983 | **Answer:**
1984 | Read Full Answer on 👉 FullStack.Cafe
1985 |
1986 | #### Q15: Define what is Let clause? ⭐⭐⭐
1987 | **Answer:**
1988 | In a query expression, it is sometimes useful to store the result of a sub-expression in order to use it in subsequent clauses. You can do this with the `let` keyword, which creates a new range variable and initializes it with the result of the expression you supply.
1989 |
1990 | Consider:
1991 | ```csharp
1992 | var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" };
1993 | var result =
1994 | from animalName in names
1995 | let nameLength = animalName.Length
1996 | where nameLength > 3
1997 | orderby nameLength
1998 | select animalName;
1999 | ```
2000 |
2001 | **Source:** _career.guru99.com_
2002 |
2003 | #### Q16: Name some advantages of LINQ over Stored Procedures ⭐⭐⭐⭐
2004 | **Answer:**
2005 | Read Full Answer on 👉 FullStack.Cafe
2006 |
2007 | #### Q17: Why do we use MSMQ? ⭐⭐
2008 | **Answer:**
2009 | **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. It's free and comes with Windows, but is not installed by default.
2010 |
2011 | This mainly addresses the common use case of asynchronous message processing: you have a service `Service1` that communicates (send messages) with another part of your software architecture, say `Service2`.
2012 |
2013 | Main problem: what if `Service2` becomes suddenly unavailable? Will messages be lost?
2014 | If you use MSMQ it won't: `Service1` will send messages into a queue, and `Service2` will dequeue when it is available.
2015 |
2016 | MSMQ will resolve following common issues:
2017 |
2018 | - temporary unavailability of a service: messages are persisted on the disk and will be dequeued when the service becomes available again, so **no messages are lost**
2019 | - as it's fully asynchronous, it'll help a lot in case of **punctual peak load**: your `Service2` won't die under the heavy load, it'll just dequeue and process messages, one after one
2020 |
2021 | **Source:** _cogin.com_
2022 |
2023 | #### Q18: Explain the Single Responsibility Principle? ⭐⭐⭐
2024 | **Answer:**
2025 | **Single responsibility** is the concept of a Class doing one specific thing (responsibility) and not trying to do more than it should, which is also referred to as _High Cohesion_.
2026 |
2027 | Classes don't often start out with Low Cohesion, but typically after several releases and different developers adding onto them, suddenly you'll notice that it became a monster or **God** class as some call it. So the class should be refactored.
2028 |
2029 | **Source:** _stackoverflow.com_
2030 |
2031 | #### Q19: What is GOD class and why should we avoid it? ⭐⭐⭐⭐
2032 | **Answer:**
2033 | Read Full Answer on 👉 FullStack.Cafe
2034 |
2035 | #### Q20: When would you use Duplex WCF service? ⭐⭐⭐⭐
2036 | **Answer:**
2037 | Read Full Answer on 👉 FullStack.Cafe
2038 |
2039 | ## [[⬆]](#toc) 20 Vue.js Interview Questions And Answers (2018 Updated)
2040 | > Originally published on 👉 20 Vue.js Interview Questions And Answers (2018 Updated) | FullStack.Cafe
2041 |
2042 | #### Q1: What is Vue.js? ⭐
2043 | **Answer:**
2044 | **Vue js** is progressive javascript script used to create dynamic user interfaces.Vue js is very easy to learn.In order to work with Vue js you just need to add few dynamic features to a website.You don’t need to install any thing to use Vue js just need add Vue js library in your project.
2045 |
2046 | **Source:** _onlineinterviewquestions.com_
2047 |
2048 | #### Q2: How to create an instance of Vue.js? ⭐
2049 | **Answer:**
2050 | Every Vue application starts by creating a new Vue instance with the Vue function:
2051 |
2052 | ```js
2053 | var vm = new Vue({
2054 | // options
2055 | })
2056 | ```
2057 |
2058 | **Source:** _onlineinterviewquestions.com_
2059 |
2060 | #### Q3: Explain the differences between one-way data flow and two-way data binding? ⭐⭐
2061 | **Answer:**
2062 | In one-way data flow the view(UI) part of application does not updates automatically when data Model is change we need to write some custom code to make it updated every time a data model is changed. In Vue js **v-bind** is used for one-way data flow or binding.
2063 |
2064 | In two-way data binding the view(UI) part of application automatically updates when data Model is changed. In Vue.js **v-model** directive is used for two way data binding.
2065 |
2066 | **Source:** _onlineinterviewquestions.com_
2067 |
2068 | #### Q4: How to create Two-Way Bindings in Vue.js? ⭐⭐
2069 | **Answer:**
2070 | `v-model` directive is used to create Two-Way Bindings in Vue js.In Two-Way Bindings data or model is bind with DOM and Dom is binded back to model.
2071 |
2072 | In below example you can see how Two-Way Bindings is implemented.
2073 |
2074 | ```html
2075 |
2076 | {{message}}
2077 |
2078 |
2079 |
2083 | ```
2084 |
2085 | **Source:** _onlineinterviewquestions.com_
2086 |
2087 | #### Q5: What are components props? ⭐⭐
2088 | **Answer:**
2089 | Every component instance has its own isolated scope. This means you cannot (and should not) directly reference parent data in a child component’s template. Data can be passed down to child components using **props**. Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance.
2090 |
2091 | ```js
2092 | Vue.component('blog-post', {
2093 | // camelCase in JavaScript
2094 | props: ['postTitle'],
2095 | template: '{{ postTitle }} '
2096 | })
2097 | ```
2098 |
2099 | **Source:** _stackoverflow.com_
2100 |
2101 | #### Q6: How to deploy Vue.js app? ⭐⭐
2102 | **Answer:**
2103 | If you've created your project like this:
2104 | ```sh
2105 | vue init webpack myproject
2106 | ```
2107 | Now you can run
2108 | ```sh
2109 | npm run build
2110 | ```
2111 | Then copy index.html and /dist/ folder into your website root directory. Done.
2112 |
2113 | **Source:** _stackoverflow.com_
2114 |
2115 | #### Q7: What are Components in Vue.js? ⭐⭐
2116 | **Answer:**
2117 | *Components* are one of most powerful features of Vue js.In Vue components are custom elements that help extend basic HTML elements to encapsulate reusable code.
2118 |
2119 | Following is the way to register a Vue component inside another component:
2120 | ```js
2121 | export default {
2122 | el: '#your-element'
2123 | components: {
2124 | 'your-component'
2125 | }
2126 | }
2127 | ```
2128 |
2129 | **Source:** _onlineinterviewquestions.com_
2130 |
2131 | #### Q8: What is filters in Vue.js? ⭐⭐
2132 | **Answer:**
2133 | Vue.js allows you to define **filters** that can be used to apply common text formatting. Filters are usable in two places: mustache interpolations and v-bind expressions (the latter supported in 2.1.0+). Filters should be appended to the end of the JavaScript expression, denoted by the “pipe” symbol:
2134 |
2135 | ```html
2136 |
2137 | {{ message | capitalize }}
2138 |
2139 |
2140 |
2141 | ```
2142 |
2143 | **Source:** _stackoverflow.com_
2144 |
2145 | #### Q9: How can you redirect to another page in Vue.js? ⭐⭐
2146 | **Answer:**
2147 | If you are using `vue-router`, you should use `router.go(path)` to navigate to any particular route. The router can be accessed from within a component using `this.$router`. `router.go()` changed in VueJS 2.0. You can use `router.push({ name: "yourroutename"})`or just `router.push("yourroutename")` now to redirect.
2148 |
2149 |
2150 | #### Q10: Explain the basic logical Vue.js app organisation ⭐⭐
2151 | **Answer:**
2152 | A **Vue.js application** consists of a root Vue instance created with new Vue, optionally organized into a tree of nested, reusable components. For example, a todo app’s component tree might look like this:
2153 |
2154 | ```sh
2155 | Root Instance
2156 | └─ TodoList
2157 | ├─ TodoItem
2158 | │ ├─ DeleteTodoButton
2159 | │ └─ EditTodoButton
2160 | └─ TodoListFooter
2161 | ├─ ClearTodosButton
2162 | └─ TodoListStatistics
2163 | ```
2164 | All Vue components are also Vue instances.
2165 |
2166 | **Source:** _vuejs.org_
2167 |
2168 | #### Q11: List some features of Vue.js ⭐⭐
2169 | **Answer:**
2170 | Vue js comes with following features
2171 |
2172 | * Templates
2173 | * Reactivity
2174 | * Components
2175 | * Transitions
2176 | * Routing
2177 |
2178 | **Source:** _onlineinterviewquestions.com_
2179 |
2180 | #### Q12: How can I fetch query parameters in Vue.js? ⭐⭐
2181 | **Answer:**
2182 | You have access to a `$route` object from your components, that expose what we need.
2183 |
2184 | ```js
2185 | //from your component
2186 | console.log(this.$route.query.test)
2187 | ```
2188 |
2189 | **Source:** _stackoverflow.com_
2190 |
2191 | #### Q13: What is the difference v-bind and v-model? Provide some code example. ⭐⭐⭐
2192 | **Answer:**
2193 | `v-model` is a **two-way binding for form inputs**. It combines `v-bind`, which **_brings a js value_ **into the markup, and `v-on:input` to **_update the js value_**.
2194 |
2195 | Consider:
2196 | ```html
2197 |
2198 | ```
2199 | and it's just syntactic sugar for:
2200 | ```html
2201 |
2205 | ```
2206 |
2207 | `v-model` works with all the basic HTML input types (text, textarea, number, radio, checkbox, select). You can use `v-model` with `input type=date` if your model stores dates as ISO strings (`yyyy-mm-dd`).
2208 |
2209 | **Source:** _stackoverflow.com_
2210 |
2211 | #### Q14: How to pass an argument to Vue.js filters? ⭐⭐⭐
2212 | **Answer:**
2213 | Consider:
2214 | ```js
2215 | filters:{
2216 | currency: function(value, arg1){
2217 | return arg1+value;
2218 | }
2219 | ```
2220 | And usage:
2221 | ```html
2222 |
2223 |
2224 | {{123 | currency('$') }}
2225 |
2226 | ```
2227 |
2228 | **Source:** _stackoverflow.com_
2229 |
2230 | #### Q15: How to use Gulp with Vue.js? ⭐⭐⭐⭐
2231 | **Answer:**
2232 | Read Full Answer on 👉 FullStack.Cafe
2233 |
2234 | #### Q16: What's the equivalent of Angular Service in Vue.js? ⭐⭐⭐⭐
2235 | **Answer:**
2236 | Read Full Answer on 👉 FullStack.Cafe
2237 |
2238 | #### Q17: What is Vuex? ⭐⭐⭐⭐
2239 | **Answer:**
2240 | Read Full Answer on 👉 FullStack.Cafe
2241 |
2242 | #### Q18: Why we need Vue.js mixins? ⭐⭐⭐⭐⭐
2243 | **Answer:**
2244 | Read Full Answer on 👉 FullStack.Cafe
2245 |
2246 | #### Q19: What is the best way to create a constant, that can be accessible from entire application in VueJs ? ⭐⭐⭐⭐⭐
2247 | **Answer:**
2248 | Read Full Answer on 👉 FullStack.Cafe
2249 |
2250 | #### Q20: What is a proper way to communicate between sibling components in vuejs 2.0? ⭐⭐⭐⭐⭐
2251 | **Answer:**
2252 | Read Full Answer on 👉 FullStack.Cafe
2253 |
2254 | ## [[⬆]](#toc) 20+ Agile Scrum Interview Questions for Software Developers in 2018
2255 | > Originally published on 👉 20+ Agile Scrum Interview Questions for Software Developers in 2018 | FullStack.Cafe
2256 |
2257 | ## [[⬆]](#toc) 22 Essential WCF Interview Questions That'll Make You Cry
2258 | > Originally published on 👉 22 Essential WCF Interview Questions That'll Make You Cry | FullStack.Cafe
2259 |
2260 | #### Q1: What is WCF? ⭐
2261 | **Answer:**
2262 | **Windows Communication Foundation (WCF)** is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data.
2263 |
2264 | **Source:** _docs.microsoft.com_
2265 |
2266 | #### Q2: Could you name basic WCF service components? ⭐⭐
2267 | **Answer:**
2268 | Have a look at this mindmap to navigate yourself through WCF service components:
2269 |
2270 |
2271 |
2272 |
2273 |
2274 | **Source:** _codeproject.com_
2275 |
2276 | #### Q3: What is a service contract in WCF? ⭐⭐
2277 | **Answer:**
2278 | A **service contract** defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do. It may have service-level settings, such as the name of the service and namespace for the service.
2279 |
2280 | ```csharp
2281 | [ServiceContract]
2282 | interface IMyContract {
2283 | [OperationContract]
2284 | string MyMethod();
2285 | }
2286 |
2287 | class MyService: IMyContract {
2288 | public string MyMethod() {
2289 | return "Hello World";
2290 | }
2291 | }
2292 | ```
2293 |
2294 | **Source:** _dotnettricks.com_
2295 |
2296 | #### Q4: Explain what is SOA? ⭐⭐
2297 | **Answer:**
2298 | **SOA** stands for **service-oriented architecture. Service Oriented Architecture is an architectural approach in software development where the application is organized as "Services". Services are a group of methods that contain the business logic to connect a DB or other services. For instance you go to a hotel and order food. Your order first goes to the counter and then it goes to the kitchen where the food is prepared and finally the waiter serves the food.
2299 |
2300 | **Some important characteristics of Service Oriented Architecture**
2301 |
2302 | * SOA services should be **independent** of other services. Altering a service should not affect the client calling the service.
2303 | * Services should be **self-contained. ** Services should be able to **define themselves** (in the Web Service Description Language (WSDL)). It should be able to tell the client what all of the operations it does, what are all the data types it uses and what kind of value it will return.
2304 |
2305 | **Source:** _c-sharpcorner.com_
2306 |
2307 | #### Q5: What are the features and advantage of WCF? ⭐⭐
2308 | **Answer:**
2309 | Features of WCF**
2310 |
2311 | Windows Communication Foundation (WCF) is a secure, reliable, and scalable messaging platform for the .NET Framework 3.0,
2312 |
2313 | * Service Orientation
2314 | * Interoperability
2315 | * Multiple Message Patterns
2316 | * Service Metadata
2317 | * Data Contracts
2318 | * Security
2319 | * Multiple Transports and Encodings
2320 | * Reliable and Queued Messages
2321 | * Durable Messages
2322 | * Transactions
2323 | * AJAX and REST Support
2324 | * Extensibility
2325 |
2326 | **Advantages of WCF**:
2327 |
2328 | 1. Service Oriented
2329 | 2. Location Independent
2330 | 3. Language Independent
2331 | 4. Platform Independent
2332 | 5. Support Multiple operation
2333 | 6. WCF can maintain transaction like COM+ Does
2334 | 7. It can maintain state
2335 | 8. It can control concurrency
2336 | 9. It can be hosted on IIS, WAS, Self hosting, Windows services.
2337 |
2338 | **Source:** _docs.microsoft.com_
2339 |
2340 | #### Q6: What is transport in WCF? ⭐⭐⭐
2341 | **Answer:**
2342 | The WCF programming model separates endpoint operations (as expressed in a service contract) from the transport mechanism that connects two endpoints. This gives you the flexibility to decide how to expose your services to the network. The transport layer is at the lowest level of the channel stack. A transport sends or receives the serialized form of a message to or from another application. The main transports used in Windows Communication Foundation (WCF) are:
2343 | * HTTP,
2344 | * HTTPS,
2345 | * TCP
2346 | * named pipes.
2347 |
2348 | **Source:** _weblogs.asp.net_
2349 |
2350 | #### Q7: What is WCF Binding and how many of them do you know? ⭐⭐⭐
2351 | **Answer:**
2352 | **Bindings** specify how a Windows Communication Foundation (WCF) service endpoint communicates with other endpoints. At its most basic, a binding must specify the _transport_ (for example, HTTP or TCP) to use. You can also set other characteristics, such as security and transaction support, through bindings.
2353 |
2354 | WCF provides nine built-in bindings:
2355 |
2356 | * **BasicHttpBinding**: Basic web service communication. Exposes WCF services as legacy ASMX web services. Used for interoperability. No security by default.
2357 | * **WSHttpBinding**: Web services with WS-* support. Supports transactions and reliable messaging.
2358 | * **WSDualHttpBinding**: Web services with duplex contract and transaction support.
2359 | * **WSFederationHttpBinding**: Web services with federated security. Supports transactions.
2360 | * **MsmqIntegrationBinding**: Communication directly with MSMQ applications. Supports transactions.
2361 | * **NetMsmqBinding**: Communication between WCF applications by using queuing. Supports transactions.
2362 | * **NetNamedPipeBinding**: Communication between WCF applications on same computer. Supports duplex contracts and transactions.
2363 | * **NetPeerTcpBinding**: Communication between computers across peer-to-peer services. Supports duplex contracts.
2364 | * **NetTcpBinding**: Communication between WCF applications across computers. Supports duplex contracts and transactions.
2365 |
2366 | **Source:** _weblogs.asp.net_
2367 |
2368 | #### Q8: What are the Possible Ways of Hosting a WCF Service? ⭐⭐⭐
2369 | **Answer:**
2370 | For a **Windows Communication Foundation** service to host, we need at least a managed process, a `ServiceHost` instance and an `Endpoint` configured. Possible approaches for hosting a service are:
2371 |
2372 | 1. Hosting in a Managed Application/Self Hosting
2373 | 1. Console Application
2374 | 2. Windows Application
2375 | 3. Windows Service
2376 | 2. Hosting on Web Server
2377 | 1. IIS 6.0 (ASP.NET Application supports only HTTP)
2378 | 2. Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP, NamedPipes, MSMQ.
2379 |
2380 | **Source:** _codeproject.com_
2381 |
2382 | #### Q9: What is Message Contract in WCF? ⭐⭐⭐
2383 | **Answer:**
2384 | Sometimes complete control over the structure of a SOAP message is just as important as control over its contents (that defined by Data Contracts). This is especially true when interoperability is important or to specifically control security issues at the level of the message or message part. In these cases, you can create a _message contract_ that enables you to specify the structure of the precise SOAP message required.
2385 |
2386 | **Source:** _c-sharpcorner.com_
2387 |
2388 | #### Q10: What is an Operation Contract in WCF? ⭐⭐⭐
2389 | **Answer:**
2390 | An **operation contract** is defined within a service contract. It defines the parameters and return type of an operation. An operation contract can also defines operation-level settings, like as the transaction flow of the operation, the directions of the operation (one-way, two-way, or both ways), and fault contract of the operation.
2391 |
2392 | ```csharp
2393 | [ServiceContract]
2394 | interface IMyContract {
2395 | [FaultContract(typeof(MyFaultContract))]
2396 | [OperationContract]
2397 | string MyMethod();
2398 | }
2399 | ```
2400 |
2401 | **Source:** _dotnettricks.com_
2402 |
2403 | #### Q11: Name some different types of contracts in WCF ⭐⭐⭐
2404 | **Answer:**
2405 | WCF contract specifies the service and its operations. WCF has five types of contracts:
2406 | * service contract,
2407 | * operation contract,
2408 | * data contract,
2409 | * message contract
2410 | * fault contract.
2411 |
2412 | **Source:** _dotnettricks.com_
2413 |
2414 | #### Q12: Explain the difference between WCF vs ASP.NET Web API? ⭐⭐⭐
2415 | **Answer:**
2416 | In the scenarios listed below you should go for WCF:
2417 |
2418 | * If you need to send data on protocols like TCP, MSMQ or MIME
2419 | * If the consuming client just knows how to consume SOAP messages
2420 | WEB API is a framework for developing RESTful/HTTP services.
2421 |
2422 | Consider:
2423 |
2424 | |WCF|ASP.NET Web API|
2425 | |--- |--- |
2426 | |Enables building services that support multiple transport protocols (HTTP, TCP, UDP, and custom transports) and allows switching between them.|HTTP only. First-class programming model for HTTP. More suitable for access from various browsers, mobile devices etc enabling wide reach.|
2427 | |Enables building services that support multiple encodings (Text, MTOM, and Binary) of the same message type and allows switching between them.|Enables building Web APIs that support wide variety of media types including XML, JSON etc.|
2428 | |Supports building services with WS-* standards like Reliable Messaging, Transactions, Message Security.|Uses basic protocol and formats such as HTTP, WebSockets, SSL, JSON, and XML. There is no support for higher level protocols such as Reliable Messaging or Transactions.|
2429 | |Supports Request-Reply, One Way, and Duplex message exchange patterns.|HTTP is request/response but additional patterns can be supported through SignalR and WebSockets integration.|
2430 | |WCF SOAP services can be described in WSDL allowing automated tools to generate client proxies even for services with complex schemas.|There is a variety of ways to describe a Web API ranging from auto-generated HTML help page describing snippets to structured metadata for OData integrated APIs.|
2431 | |Ships with the .NET framework.|Ships with .NET framework but is open-source and is also available out-of-band as independent download.|
2432 |
2433 | **Source:** _stackoverflow.com_
2434 |
2435 | #### Q13: Why we need Streaming? ⭐⭐⭐
2436 | **Answer:**
2437 | When you have a large amount of data to transfer, the streaming transfer mode in WCF is a feasible alternative to the default behavior of buffering and processing messages in memory in their entirety.
2438 |
2439 | In WCF any receiving message is delivered only once the entire message has been received. What I mean here is that first message is buffered at the receiving side and once it is fully received it gets delivered to the receiving end. The main problem with this approach is that the receiver end is unresponsive while the message is getting buffered. So default way of message handling in WCF is ok for small size messages but for the large size messages, this approach is not good. So to overcome this problem Streaming in WCF come into action.
2440 |
2441 | **Source:** _c-sharpcorner.com_
2442 |
2443 | #### Q14: What is interoperability and how is it achieved with WCF services? ⭐⭐⭐⭐
2444 | **Answer:**
2445 | Read Full Answer on 👉 FullStack.Cafe
2446 |
2447 | #### Q15: When would you use Duplex WCF service? ⭐⭐⭐⭐
2448 | **Answer:**
2449 | Read Full Answer on 👉 FullStack.Cafe
2450 |
2451 | #### Q16: Will it make any difference if I change the operation contract of methods having no return value by [OperationContract(IsOneWay=true)]? ⭐⭐⭐⭐
2452 | **Answer:**
2453 | Read Full Answer on 👉 FullStack.Cafe
2454 |
2455 | #### Q17: Explain Binary vs MTOM vs Streaming in WCF? ⭐⭐⭐⭐⭐
2456 | **Answer:**
2457 | Read Full Answer on 👉 FullStack.Cafe
2458 |
2459 | #### Q18: What is the difference between hosting WCF service on IIS, Windows Service and self-hosted app? ⭐⭐⭐⭐⭐
2460 | **Answer:**
2461 | Read Full Answer on 👉 FullStack.Cafe
2462 |
2463 | #### Q19: Could we use WSHttpBinding with Request-CallBack (also called Duplex) exchange pattern? ⭐⭐⭐⭐⭐
2464 | **Answer:**
2465 | Read Full Answer on 👉 FullStack.Cafe
2466 |
2467 | #### Q20: What is the main difference between Request-Response and Duplex in WCF Message Exchange Pattern? ⭐⭐⭐⭐⭐
2468 | **Answer:**
2469 | Read Full Answer on 👉 FullStack.Cafe
2470 |
2471 | #### Q21: Should I use WCF or raw sockets? ⭐⭐⭐⭐⭐
2472 | **Answer:**
2473 | Read Full Answer on 👉 FullStack.Cafe
2474 |
2475 | #### Q22: What replaces WCF in .Net Core? ⭐⭐⭐⭐⭐
2476 | **Answer:**
2477 | Read Full Answer on 👉 FullStack.Cafe
2478 |
2479 | ## [[⬆]](#toc) 22 Important JavaScript/ES6/ES2015 Interview Questions
2480 | > Originally published on 👉 22 Important JavaScript/ES6/ES2015 Interview Questions | FullStack.Cafe
2481 |
2482 | #### Q1: Could you explain the difference between ES5 and ES6 ⭐⭐⭐
2483 | **Answer:**
2484 | * **ECMAScript 5 (ES5)**: The 5th edition of ECMAScript, standardized in 2009. This standard has been implemented fairly completely in all modern browsers
2485 |
2486 | * **ECMAScript 6 (ES6)/ ECMAScript 2015 (ES2015)**: The 6th edition of ECMAScript, standardized in 2015. This standard has been partially implemented in most modern browsers.
2487 |
2488 | Here are some key differences between ES5 and ES6:
2489 | * **Arrow functions** & **string interpolation**:
2490 | Consider:
2491 | ```js
2492 | const greetings = (name) => {
2493 | return `hello ${name}`;
2494 | }
2495 | ```
2496 | and even:
2497 | ```js
2498 | const greetings = name => `hello ${name}`;
2499 | ```
2500 | * **Const**.
2501 | Const works like a constant in other languages in many ways but there are some caveats. Const stands for ‘constant reference’ to a value. So with const, you can actually mutate the properties of an object being referenced by the variable. You just can’t change the reference itself.
2502 | ```js
2503 | const NAMES = [];
2504 | NAMES.push("Jim");
2505 | console.log(NAMES.length === 1); // true
2506 | NAMES = ["Steve", "John"]; // error
2507 | ```
2508 | * **Block-scoped variables**.
2509 | The new ES6 keyword `let` allows developers to scope variables at the block level.
2510 | `Let` doesn’t hoist in the same way `var` does.
2511 | * **Default parameter values**
2512 | Default parameters allow us to initialize functions with default values. A default is used when an argument is either omitted or undefined — meaning null is a valid value.
2513 | ```js
2514 | // Basic syntax
2515 | function multiply (a, b = 2) {
2516 | return a * b;
2517 | }
2518 | multiply(5); // 10
2519 | ```
2520 | * ** Class Definition and Inheritance**
2521 | ES6 introduces language support for classes (`class` keyword), constructors (`constructor` keyword), and the `extend` keyword for inheritance.
2522 |
2523 | * **for-of operator**
2524 | The for...of statement creates a loop iterating over iterable objects.
2525 | * **Spread Operator**
2526 | For objects merging
2527 | ```js
2528 | const obj1 = { a: 1, b: 2 }
2529 | const obj2 = { a: 2, c: 3, d: 4}
2530 | const obj3 = {...obj1, ...obj2}
2531 | ```
2532 | * **Promises**
2533 | Promises provide a mechanism to handle the results and errors from asynchronous operations. You can accomplish the same thing with callbacks, but promises provide improved readability via method chaining and succinct error handling.
2534 | ```js
2535 | const isGreater = (a, b) => {
2536 | return new Promise ((resolve, reject) => {
2537 | if(a > b) {
2538 | resolve(true)
2539 | } else {
2540 | reject(false)
2541 | }
2542 | })
2543 | }
2544 | isGreater(1, 2)
2545 | .then(result => {
2546 | console.log('greater')
2547 | })
2548 | .catch(result => {
2549 | console.log('smaller')
2550 | })
2551 | ```
2552 | * **Modules exporting & importing**
2553 | Consider module exporting:
2554 | ```js
2555 | const myModule = { x: 1, y: () => { console.log('This is ES5') }}
2556 | export default myModule;
2557 | ```
2558 | and importing:
2559 | ```js
2560 | import myModule from './myModule';
2561 | ```
2562 |
2563 |
2564 | #### Q2: What is IIFEs (Immediately Invoked Function Expressions)? ⭐⭐⭐
2565 | **Answer:**
2566 | It’s an Immediately-Invoked Function Expression, or IIFE for short. It executes immediately after it’s created:
2567 | ```js
2568 | (function IIFE(){
2569 | console.log( "Hello!" );
2570 | })();
2571 | // "Hello!"
2572 | ```
2573 |
2574 | This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.
2575 |
2576 | **Source:** _stackoverflow.com_
2577 |
2578 | #### Q3: When should I use Arrow functions in ES6? ⭐⭐⭐
2579 | **Answer:**
2580 | I'm now using the following rule of thumb for functions in ES6 and beyond:
2581 |
2582 | * Use `function` in the global scope and for Object.prototype properties.
2583 | * Use `class` for object constructors.
2584 | * Use `=>` everywhere else.
2585 |
2586 | Why use arrow functions almost everywhere?
2587 |
2588 | * **Scope safety**: When arrow functions are used consistently, everything is guaranteed to use the same thisObject as the root. If even a single standard function callback is mixed in with a bunch of arrow functions there's a chance the scope will become messed up.
2589 | * **Compactness**: Arrow functions are easier to read and write. (This may seem opinionated so I will give a few examples further on).
2590 | * **Clarity**: When almost everything is an arrow function, any regular function immediately sticks out for defining the scope. A developer can always look up the next-higher function statement to see what the thisObject is.
2591 |
2592 | **Source:** _stackoverflow.com_
2593 |
2594 | #### Q4: What is the motivation for bringing Symbols to ES6? ⭐⭐⭐
2595 | **Answer:**
2596 | `Symbols` are a new, special kind of object that can be used as a unique property name in objects. Using `Symbol` instead of `string`'s allows different modules to create properties that don't conflict with one another. `Symbols` can also be made private, so that their properties can't be accessed by anyone who doesn't already have direct access to the `Symbol`.
2597 |
2598 | `Symbols` are a new **primitive**. Just like the `number`, `string`, and `boolean` primitives, `Symbol` have a function which can be used to create them. Unlike the other primitives, `Symbols` do not have a literal syntax (e.g how `string` have `''`) - the only way to create them is with the `Symbol` constructor in the following way:
2599 |
2600 | ```js
2601 | let symbol = Symbol();
2602 | ```
2603 |
2604 | In reality, `Symbol`'s are just a slightly different way to attach properties to an object - you could easily provide the well-known `Symbols` as standard methods, just like `Object.prototype.hasOwnProperty` which appears in everything that inherits from `Object`.
2605 |
2606 | **Source:** _stackoverflow.com_
2607 |
2608 | #### Q5: What are the benefits of using spread syntax in ES6 and how is it different from rest syntax? ⭐⭐⭐
2609 | **Answer:**
2610 | ES6's spread syntax is very useful when coding in a functional paradigm as we can easily create copies of arrays or objects without resorting to `Object.create`, `slice`, or a library function. This language feature is used often in Redux and rx.js projects.
2611 |
2612 | ```js
2613 | function putDookieInAnyArray(arr) {
2614 | return [...arr, 'dookie'];
2615 | }
2616 |
2617 | const result = putDookieInAnyArray(['I', 'really', "don't", 'like']); // ["I", "really", "don't", "like", "dookie"]
2618 |
2619 | const person = {
2620 | name: 'Todd',
2621 | age: 29,
2622 | };
2623 |
2624 | const copyOfTodd = { ...person };
2625 | ```
2626 |
2627 | ES6's rest syntax offers a shorthand for including an arbitrary number of arguments to be passed to a function. It is like an inverse of the spread syntax, taking data and stuffing it into an array rather than unpacking an array of data, and it works in function arguments, as well as in array and object destructuring assignments.
2628 |
2629 | ```js
2630 | function addFiveToABunchOfNumbers(...numbers) {
2631 | return numbers.map(x => x + 5);
2632 | }
2633 |
2634 | const result = addFiveToABunchOfNumbers(4, 5, 6, 7, 8, 9, 10); // [9, 10, 11, 12, 13, 14, 15]
2635 |
2636 | const [a, b, ...rest] = [1, 2, 3, 4]; // a: 1, b: 2, rest: [3, 4]
2637 |
2638 | const { e, f, ...others } = {
2639 | e: 1,
2640 | f: 2,
2641 | g: 3,
2642 | h: 4,
2643 | }; // e: 1, f: 2, others: { g: 3, h: 4 }
2644 | ```
2645 |
2646 | **Source:** _github.com/yangshun_
2647 |
2648 | #### Q6: What are the differences between ES6 class and ES5 function constructors? ⭐⭐⭐
2649 | **Answer:**
2650 | Let's first look at example of each:
2651 |
2652 | ```js
2653 | // ES5 Function Constructor
2654 | function Person(name) {
2655 | this.name = name;
2656 | }
2657 |
2658 | // ES6 Class
2659 | class Person {
2660 | constructor(name) {
2661 | this.name = name;
2662 | }
2663 | }
2664 | ```
2665 |
2666 | For simple constructors, they look pretty similar.
2667 |
2668 | The main difference in the constructor comes when using inheritance. If we want to create a `Student` class that subclasses `Person` and add a `studentId` field, this is what we have to do in addition to the above.
2669 |
2670 | ```js
2671 | // ES5 Function Constructor
2672 | function Student(name, studentId) {
2673 | // Call constructor of superclass to initialize superclass-derived members.
2674 | Person.call(this, name);
2675 |
2676 | // Initialize subclass's own members.
2677 | this.studentId = studentId;
2678 | }
2679 |
2680 | Student.prototype = Object.create(Person.prototype);
2681 | Student.prototype.constructor = Student;
2682 |
2683 | // ES6 Class
2684 | class Student extends Person {
2685 | constructor(name, studentId) {
2686 | super(name);
2687 | this.studentId = studentId;
2688 | }
2689 | }
2690 | ```
2691 |
2692 | It's much more verbose to use inheritance in ES5 and the ES6 version is easier to understand and remember.
2693 |
2694 | **Source:** _github.com/yangshun_
2695 |
2696 | #### Q7: What's the difference between `.call` and `.apply`? ⭐⭐⭐
2697 | **Answer:**
2698 | Both `.call` and `.apply` are used to invoke functions and the first parameter will be used as the value of `this` within the function. However, `.call` takes in comma-separated arguments as the next arguments while `.apply` takes in an array of arguments as the next argument. An easy way to remember this is C for `call` and comma-separated and A for `apply` and an array of arguments.
2699 |
2700 | ```js
2701 | function add(a, b) {
2702 | return a + b;
2703 | }
2704 |
2705 | console.log(add.call(null, 1, 2)); // 3
2706 | console.log(add.apply(null, [1, 2])); // 3
2707 | ```
2708 |
2709 |
2710 | **Source:** _github.com/yangshun_
2711 |
2712 | #### Q8: Why should we use ES6 classes? ⭐⭐⭐
2713 | **Answer:**
2714 | Some reasons you might choose to use **Classes**:
2715 |
2716 | * The syntax is simpler and less error-prone.
2717 | * It's **much** easier (and again, less error-prone) to set up inheritance hierarchies using the new syntax than with the old.
2718 | * `class` defends you from the common error of failing to use `new` with the constructor function (by having the constructor throw an exception if `this` isn't a valid object for the constructor).
2719 | * Calling the parent prototype's version of a method is much simpler with the new syntax than the old (`super.method()` instead of `ParentConstructor.prototype.method.call(this)` or `Object.getPrototypeOf(Object.getPrototypeOf(this)).method.call(this)`).
2720 |
2721 | Consider:
2722 | ```js
2723 | // **ES5**
2724 | var Person = function(first, last) {
2725 | if (!(this instanceof Person)) {
2726 | throw new Error("Person is a constructor function, use new with it");
2727 | }
2728 | this.first = first;
2729 | this.last = last;
2730 | };
2731 |
2732 | Person.prototype.personMethod = function() {
2733 | return "Result from personMethod: this.first = " + this.first + ", this.last = " + this.last;
2734 | };
2735 |
2736 | var Employee = function(first, last, position) {
2737 | if (!(this instanceof Employee)) {
2738 | throw new Error("Employee is a constructor function, use new with it");
2739 | }
2740 | Person.call(this, first, last);
2741 | this.position = position;
2742 | };
2743 | Employee.prototype = Object.create(Person.prototype);
2744 | Employee.prototype.constructor = Employee;
2745 | Employee.prototype.personMethod = function() {
2746 | var result = Person.prototype.personMethod.call(this);
2747 | return result + ", this.position = " + this.position;
2748 | };
2749 | Employee.prototype.employeeMethod = function() {
2750 | // ...
2751 | };
2752 | ```
2753 | And the same with ES6 classes:
2754 | ```js
2755 | // ***ES2015+**
2756 | class Person {
2757 | constructor(first, last) {
2758 | this.first = first;
2759 | this.last = last;
2760 | }
2761 |
2762 | personMethod() {
2763 | // ...
2764 | }
2765 | }
2766 |
2767 | class Employee extends Person {
2768 | constructor(first, last, position) {
2769 | super(first, last);
2770 | this.position = position;
2771 | }
2772 |
2773 | employeeMethod() {
2774 | // ...
2775 | }
2776 | }
2777 | ```
2778 |
2779 |
2780 | **Source:** _stackoverflow.com_
2781 |
2782 | #### Q9: What is the preferred syntax for defining enums in JavaScript? ⭐⭐⭐
2783 | **Answer:**
2784 | Since 1.8.5 it's possible to seal and freeze the object, so define the above as:
2785 |
2786 | ```js
2787 | var DaysEnum = Object.freeze({
2788 | "monday": 1,
2789 | "tuesday": 2,
2790 | "wednesday": 3,
2791 | ...
2792 | })
2793 | ```
2794 |
2795 | or
2796 |
2797 | ```js
2798 | var DaysEnum = {
2799 | "monday": 1,
2800 | "tuesday": 2,
2801 | "wednesday": 3,
2802 | ...
2803 | }
2804 | Object.freeze(DaysEnum)
2805 | ```
2806 |
2807 | and voila! JS enums.
2808 |
2809 | However, this doesn't prevent you from assigning an undesired value to a variable, which is often the main goal of enums:
2810 |
2811 | ```js
2812 | let day = DaysEnum.tuesday
2813 | day = 298832342 // goes through without any errors
2814 | ```
2815 |
2816 | **Source:** _stackoverflow.com_
2817 |
2818 | #### Q10: Explain the difference between Object.freeze() vs const ⭐⭐⭐
2819 | **Answer:**
2820 | `const` and `Object.freeze` are two completely different things.
2821 |
2822 | * `const` applies to **bindings** ("variables"). It creates an immutable binding, i.e. you cannot assign a new value to the binding.
2823 | ```js
2824 | const person = {
2825 | name: "Leonardo"
2826 | };
2827 | let animal = {
2828 | species: "snake"
2829 | };
2830 | person = animal; // ERROR "person" is read-only
2831 | ```
2832 | * `Object.freeze` works on **values**, and more specifically, *object values*. It makes an object immutable, i.e. you cannot change its properties.
2833 | ```js
2834 | let person = {
2835 | name: "Leonardo"
2836 | };
2837 | let animal = {
2838 | species: "snake"
2839 | };
2840 | Object.freeze(person);
2841 | person.name = "Lima"; //TypeError: Cannot assign to read only property 'name' of object
2842 | console.log(person);
2843 | ```
2844 |
2845 | **Source:** _stackoverflow.com_
2846 |
2847 | #### Q11: What is generator in JS? ⭐⭐⭐
2848 | **Answer:**
2849 | Generators are functions which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances. Generator functions are written using the `function*` syntax. When called initially, generator functions do not execute any of their code, instead returning a type of iterator called a Generator. When a value is consumed by calling the generator's `next` method, the Generator function executes until it encounters the `yield` keyword.
2850 |
2851 | The function can be called as many times as desired and returns a new Generator each time, however each Generator may only be iterated once.
2852 |
2853 | ```js
2854 | function* makeRangeIterator(start = 0, end = Infinity, step = 1) {
2855 | let iterationCount = 0;
2856 | for (let i = start; i < end; i += step) {
2857 | iterationCount++;
2858 | yield i;
2859 | }
2860 | return iterationCount;
2861 | }
2862 | ```
2863 |
2864 | **Source:** _stackoverflow.com_
2865 |
2866 | #### Q12: What is Hoisting in JavaScript? ⭐⭐⭐⭐
2867 | **Answer:**
2868 | Read Full Answer on 👉 FullStack.Cafe
2869 |
2870 | #### Q13: Explain the Prototype Design Pattern ⭐⭐⭐⭐
2871 | **Answer:**
2872 | Read Full Answer on 👉 FullStack.Cafe
2873 |
2874 | #### Q14: What is the Temporal Dead Zone in ES6? ⭐⭐⭐⭐
2875 | **Answer:**
2876 | Read Full Answer on 👉 FullStack.Cafe
2877 |
2878 | #### Q15: When should you NOT use arrow functions in ES6? Name three or more cases. ⭐⭐⭐⭐
2879 | **Answer:**
2880 | Read Full Answer on 👉 FullStack.Cafe
2881 |
2882 | #### Q16: What are the actual uses of ES6 WeakMap? ⭐⭐⭐⭐
2883 | **Answer:**
2884 | Read Full Answer on 👉 FullStack.Cafe
2885 |
2886 | #### Q17: Explain why the following doesn't work as an IIFE. What needs to be changed to properly make it an IIFE? ⭐⭐⭐⭐
2887 | **Details:**
2888 | ```js
2889 | function foo(){ }();
2890 | ```
2891 |
2892 | **Answer:**
2893 | Read Full Answer on 👉 FullStack.Cafe
2894 |
2895 | #### Q18: Could you compare usage of Module Pattern vs Constructor/Prototype pattern? ⭐⭐⭐⭐
2896 | **Answer:**
2897 | Read Full Answer on 👉 FullStack.Cafe
2898 |
2899 | #### Q19: What's the difference between ES6 Map and WeakMap? ⭐⭐⭐⭐⭐
2900 | **Answer:**
2901 | Read Full Answer on 👉 FullStack.Cafe
2902 |
2903 | #### Q20: Can you give an example of a curry function and why this syntax offers an advantage? ⭐⭐⭐⭐⭐
2904 | **Answer:**
2905 | Read Full Answer on 👉 FullStack.Cafe
2906 |
2907 | #### Q21: How to "deep-freeze" object in JavaScript? ⭐⭐⭐⭐⭐
2908 | **Answer:**
2909 | Read Full Answer on 👉 FullStack.Cafe
2910 |
2911 | #### Q22: Compare Async/Await and Generators usage to achive same functionality ⭐⭐⭐⭐⭐
2912 | **Answer:**
2913 | Read Full Answer on 👉 FullStack.Cafe
2914 |
2915 | ## [[⬆]](#toc) 22+ Angular 6 Interview Questions to Stand Out in 2018
2916 | > Originally published on 👉 22+ Angular 6 Interview Questions to Stand Out in 2018 | FullStack.Cafe
2917 |
2918 | #### Q1: What is difference between "declarations", "providers" and "import" in NgModule? ⭐⭐⭐
2919 | **Answer:**
2920 | * `imports` makes the exported declarations of other modules available in the current module
2921 | * `declarations` are to make directives (including components and pipes) from the current module available to other directives in the current module. Selectors of directives, components or pipes are only matched against the HTML if they are declared or imported.
2922 | * `providers` are to make services and values known to DI. They are added to the root scope and they are injected to other services or directives that have them as dependency.
2923 |
2924 | A special case for `providers` are lazy loaded modules that get their own child injector. `providers` of a lazy loaded module are only provided to this lazy loaded module by default (not the whole application as it is with other modules).
2925 |
2926 | **Source:** _medium.com_
2927 |
2928 | #### Q2: What is AOT? ⭐⭐⭐
2929 | **Answer:**
2930 | The Angular Ahead-of-Time compiler pre-compiles application components and their templates during the build process.
2931 | Apps compiled with AOT launch faster for several reasons.
2932 | * Application components execute immediately, without client-side compilation.
2933 | * Templates are embedded as code within their components so there is no client-side request for template files.
2934 | * You don't download the Angular compiler, which is pretty big on its own.
2935 | * The compiler discards unused Angular directives that a tree-shaking tool can then exclude.
2936 |
2937 | **Source:** _stackoverflow.com_
2938 |
2939 | #### Q3: Explain the difference between "Constructor" and "ngOnInit" ⭐⭐⭐
2940 | **Answer:**
2941 | * The `Constructor` is a default method of the class that is executed when the class is instantiated and ensures proper initialization of fields in the class and its subclasses.
2942 | * `ngOnInit` is a life cycle hook called by Angular to indicate that Angular is done creating the component. We have to import OnInit in order to use like this (actually implementing OnInit is not mandatory but considered good practice).
2943 |
2944 | Mostly we use `ngOnInit` for all the initialization/declaration and avoid stuff to work in the constructor. The constructor should only be used to initialize class members but shouldn't do actual "work".
2945 |
2946 | **Source:** _stackoverflow.com_
2947 |
2948 | #### Q4: What's new in Angular 6 and why shall we upgrade to it? ⭐⭐⭐
2949 | **Answer:**
2950 | * **Angular Elements** - Angular Elements is a project that lets you wrap your Angular components as Web Components and embed them in a non-Angular application.
2951 | * **New Rendering Engine: Ivy** - increases in speed and decreases in application size.
2952 | * **Tree-shakeable providers** - a new, recommended, way to register a provider, directly inside the @Injectable() decorator, using the new `providedIn` attribute
2953 | * **RxJS 6** - Angular 6 now uses RxJS 6 internally, and requires you to update your application also. RxJS released a library called rxjs-compat, that allows you to bump RxJS to version 6.0 even if you, or one of the libraries you’re using, is still using one of the “old” syntaxes.
2954 | * **ElementRef``** - in Angular 5.0 or older, is that the said ElementRef had its nativeElement property typed as any. In Angular 6.0, you can now type ElementRef more strictly.
2955 | * **Animations** - The polyfill web-animations-js is not necessary anymore for animations in Angular 6.0, except if you are using the AnimationBuilder.
2956 | * **i18n** - possibility to have “runtime i18n”, without having to build the application once per locale.
2957 |
2958 |
2959 | **Source:** _ninja-squad.com_
2960 |
2961 | #### Q5: Why would you use renderer methods instead of using native element methods? ⭐⭐⭐⭐
2962 | **Answer:**
2963 | Read Full Answer on 👉 FullStack.Cafe
2964 |
2965 | #### Q6: What is Zone in Angular? ⭐⭐⭐⭐
2966 | **Answer:**
2967 | Read Full Answer on 👉 FullStack.Cafe
2968 |
2969 | #### Q7: Why would you use lazy loading modules in Angular app? ⭐⭐⭐⭐
2970 | **Answer:**
2971 | Read Full Answer on 👉 FullStack.Cafe
2972 |
2973 | #### Q8: What are the lifecycle hooks for components and directives? ⭐⭐⭐⭐
2974 | **Answer:**
2975 | Read Full Answer on 👉 FullStack.Cafe
2976 |
2977 | #### Q9: How would you insert an embedded view from a prepared TemplateRef? ⭐⭐⭐⭐
2978 | **Answer:**
2979 | Read Full Answer on 👉 FullStack.Cafe
2980 |
2981 | #### Q10: How to detect a route change in Angular? ⭐⭐⭐⭐
2982 | **Answer:**
2983 | Read Full Answer on 👉 FullStack.Cafe
2984 |
2985 | #### Q11: What does a just-in-time (JIT) compiler do (in general)? ⭐⭐⭐⭐
2986 | **Answer:**
2987 | Read Full Answer on 👉 FullStack.Cafe
2988 |
2989 | #### Q12: How do you create application to use scss? What changed for Angular 6? ⭐⭐⭐⭐
2990 | **Answer:**
2991 | Read Full Answer on 👉 FullStack.Cafe
2992 |
2993 | #### Q13: What is ngUpgrage? ⭐⭐⭐⭐
2994 | **Answer:**
2995 | Read Full Answer on 👉 FullStack.Cafe
2996 |
2997 | #### Q14: What is Reactive programming and how does it relate to Angular? ⭐⭐⭐⭐
2998 | **Answer:**
2999 | Read Full Answer on 👉 FullStack.Cafe
3000 |
3001 | #### Q15: Name some security best practices in Angular ⭐⭐⭐⭐
3002 | **Answer:**
3003 | Read Full Answer on 👉 FullStack.Cafe
3004 |
3005 | #### Q16: Could I use jQuery with Angular? ⭐⭐⭐⭐
3006 | **Answer:**
3007 | Read Full Answer on 👉 FullStack.Cafe
3008 |
3009 | #### Q17: What is the Angular equivalent to an AngularJS "$watch"? ⭐⭐⭐⭐⭐
3010 | **Answer:**
3011 | Read Full Answer on 👉 FullStack.Cafe
3012 |
3013 | #### Q18: Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation. Explain the difference. ⭐⭐⭐⭐⭐
3014 | **Answer:**
3015 | Read Full Answer on 👉 FullStack.Cafe
3016 |
3017 | #### Q19: Do you know how you can run angularJS and angular side by side? ⭐⭐⭐⭐⭐
3018 | **Answer:**
3019 | Read Full Answer on 👉 FullStack.Cafe
3020 |
3021 | #### Q20: Could you provide some particular examples of using ngZone? ⭐⭐⭐⭐⭐
3022 | **Answer:**
3023 | Read Full Answer on 👉 FullStack.Cafe
3024 |
3025 | #### Q21: Why angular uses url segment? ⭐⭐⭐⭐⭐
3026 | **Answer:**
3027 | Read Full Answer on 👉 FullStack.Cafe
3028 |
3029 | #### Q22: When to use query parameters versus matrix parameters? ⭐⭐⭐⭐⭐
3030 | **Details:**
3031 | * Query parameters: http://example.com/apples?order=random&color=blue
3032 | * Matrix parameters: http://example.com/apples;order=random;color=blue
3033 |
3034 | **Answer:**
3035 | Read Full Answer on 👉 FullStack.Cafe
3036 |
3037 | ## [[⬆]](#toc) 23 Advanced JavaScript Interview Questions
3038 | > Originally published on 👉 23 Advanced JavaScript Interview Questions | FullStack.Cafe
3039 |
3040 | #### Q1: Explain equality in JavaScript ⭐
3041 | **Answer:**
3042 | JavaScript has both strict and type–converting comparisons:
3043 | * **Strict comparison (e.g., ===)** checks for value equality without allowing *coercion*
3044 | * **Abstract comparison (e.g. ==)** checks for value equality with *coercion* allowed
3045 |
3046 | ```js
3047 | var a = "42";
3048 | var b = 42;
3049 |
3050 | a == b; // true
3051 | a === b; // false
3052 | ```
3053 | Some simple equalityrules:
3054 | * If either value (aka side) in a comparison could be the `true` or `false` value, avoid `==` and use `===`.
3055 | * If either value in a comparison could be of these specific values (`0`, `""`, or `[]` -- empty array), avoid `==` and use `===`.
3056 | * In all other cases, you're safe to use `==`. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.
3057 |
3058 | #### Q2: Provide some examples of non-bulean value coercion to a boolean one ⭐⭐⭐
3059 | **Answer:**
3060 | The question is when a non-boolean value is coerced to a boolean, does it become `true` or `false`, respectively?
3061 |
3062 | The specific list of "falsy" values in JavaScript is as follows:
3063 |
3064 | * `""` (empty string)
3065 | * `0`, `-0`, `NaN` (invalid number)
3066 | * `null`, `undefined`
3067 | * `false`
3068 |
3069 | Any value that's not on this "falsy" list is "truthy." Here are some examples of those:
3070 |
3071 | * `"hello"`
3072 | * `42`
3073 | * `true`
3074 | * `[ ]`, `[ 1, "2", 3 ]` (arrays)
3075 | * `{ }`, `{ a: 42 }` (objects)
3076 | * `function foo() { .. }` (functions)
3077 |
3078 |
3079 | #### Q3: What is IIFEs (Immediately Invoked Function Expressions)? ⭐⭐⭐
3080 | **Answer:**
3081 | It’s an Immediately-Invoked Function Expression, or IIFE for short. It executes immediately after it’s created:
3082 | ```js
3083 | (function IIFE(){
3084 | console.log( "Hello!" );
3085 | })();
3086 | // "Hello!"
3087 | ```
3088 |
3089 | This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.
3090 |
3091 | **Source:** _stackoverflow.com_
3092 |
3093 | #### Q4: When should I use Arrow functions in ES6? ⭐⭐⭐
3094 | **Answer:**
3095 | I'm now using the following rule of thumb for functions in ES6 and beyond:
3096 |
3097 | * Use `function` in the global scope and for Object.prototype properties.
3098 | * Use `class` for object constructors.
3099 | * Use `=>` everywhere else.
3100 |
3101 | Why use arrow functions almost everywhere?
3102 |
3103 | * **Scope safety**: When arrow functions are used consistently, everything is guaranteed to use the same thisObject as the root. If even a single standard function callback is mixed in with a bunch of arrow functions there's a chance the scope will become messed up.
3104 | * **Compactness**: Arrow functions are easier to read and write. (This may seem opinionated so I will give a few examples further on).
3105 | * **Clarity**: When almost everything is an arrow function, any regular function immediately sticks out for defining the scope. A developer can always look up the next-higher function statement to see what the thisObject is.
3106 |
3107 | **Source:** _stackoverflow.com_
3108 |
3109 | #### Q5: What are the differences between ES6 class and ES5 function constructors? ⭐⭐⭐
3110 | **Answer:**
3111 | Let's first look at example of each:
3112 |
3113 | ```js
3114 | // ES5 Function Constructor
3115 | function Person(name) {
3116 | this.name = name;
3117 | }
3118 |
3119 | // ES6 Class
3120 | class Person {
3121 | constructor(name) {
3122 | this.name = name;
3123 | }
3124 | }
3125 | ```
3126 |
3127 | For simple constructors, they look pretty similar.
3128 |
3129 | The main difference in the constructor comes when using inheritance. If we want to create a `Student` class that subclasses `Person` and add a `studentId` field, this is what we have to do in addition to the above.
3130 |
3131 | ```js
3132 | // ES5 Function Constructor
3133 | function Student(name, studentId) {
3134 | // Call constructor of superclass to initialize superclass-derived members.
3135 | Person.call(this, name);
3136 |
3137 | // Initialize subclass's own members.
3138 | this.studentId = studentId;
3139 | }
3140 |
3141 | Student.prototype = Object.create(Person.prototype);
3142 | Student.prototype.constructor = Student;
3143 |
3144 | // ES6 Class
3145 | class Student extends Person {
3146 | constructor(name, studentId) {
3147 | super(name);
3148 | this.studentId = studentId;
3149 | }
3150 | }
3151 | ```
3152 |
3153 | It's much more verbose to use inheritance in ES5 and the ES6 version is easier to understand and remember.
3154 |
3155 | **Source:** _github.com/yangshun_
3156 |
3157 | #### Q6: Explain `Function.prototype.bind`. ⭐⭐⭐
3158 | **Answer:**
3159 | Taken word-for-word from [MDN](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind):
3160 |
3161 | > The `bind()` method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.
3162 |
3163 | In my experience, it is most useful for binding the value of `this` in methods of classes that you want to pass into other functions. This is frequently done in React components.
3164 |
3165 | **Source:** _github.com/yangshun_
3166 |
3167 | #### Q7: What's a typical use case for anonymous functions? ⭐⭐⭐
3168 | **Answer:**
3169 | They can be used in IIFEs to encapsulate some code within a local scope so that variables declared in it do not leak to the global scope.
3170 |
3171 | ```js
3172 | (function() {
3173 | // Some code here.
3174 | })();
3175 | ```
3176 |
3177 | As a callback that is used once and does not need to be used anywhere else. The code will seem more self-contained and readable when handlers are defined right inside the code calling them, rather than having to search elsewhere to find the function body.
3178 |
3179 | ```js
3180 | setTimeout(function() {
3181 | console.log('Hello world!');
3182 | }, 1000);
3183 | ```
3184 |
3185 | Arguments to functional programming constructs or Lodash (similar to callbacks).
3186 |
3187 | ```js
3188 | const arr = [1, 2, 3];
3189 | const double = arr.map(function(el) {
3190 | return el * 2;
3191 | });
3192 | console.log(double); // [2, 4, 6]
3193 | ```
3194 |
3195 | **Source:** _github.com/yangshun_
3196 |
3197 | #### Q8: Explain the difference between Object.freeze() vs const ⭐⭐⭐
3198 | **Answer:**
3199 | `const` and `Object.freeze` are two completely different things.
3200 |
3201 | * `const` applies to **bindings** ("variables"). It creates an immutable binding, i.e. you cannot assign a new value to the binding.
3202 | ```js
3203 | const person = {
3204 | name: "Leonardo"
3205 | };
3206 | let animal = {
3207 | species: "snake"
3208 | };
3209 | person = animal; // ERROR "person" is read-only
3210 | ```
3211 | * `Object.freeze` works on **values**, and more specifically, *object values*. It makes an object immutable, i.e. you cannot change its properties.
3212 | ```js
3213 | let person = {
3214 | name: "Leonardo"
3215 | };
3216 | let animal = {
3217 | species: "snake"
3218 | };
3219 | Object.freeze(person);
3220 | person.name = "Lima"; //TypeError: Cannot assign to read only property 'name' of object
3221 | console.log(person);
3222 | ```
3223 |
3224 | **Source:** _stackoverflow.com_
3225 |
3226 | #### Q9: What is generator in JS? ⭐⭐⭐
3227 | **Answer:**
3228 | Generators are functions which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances. Generator functions are written using the `function*` syntax. When called initially, generator functions do not execute any of their code, instead returning a type of iterator called a Generator. When a value is consumed by calling the generator's `next` method, the Generator function executes until it encounters the `yield` keyword.
3229 |
3230 | The function can be called as many times as desired and returns a new Generator each time, however each Generator may only be iterated once.
3231 |
3232 | ```js
3233 | function* makeRangeIterator(start = 0, end = Infinity, step = 1) {
3234 | let iterationCount = 0;
3235 | for (let i = start; i < end; i += step) {
3236 | iterationCount++;
3237 | yield i;
3238 | }
3239 | return iterationCount;
3240 | }
3241 | ```
3242 |
3243 | **Source:** _stackoverflow.com_
3244 |
3245 | #### Q10: When should we use generators in ES6? ⭐⭐⭐
3246 | **Answer:**
3247 | To put it simple, generator has two features:
3248 |
3249 | * one can choose to jump out of a function and let outer code to determine when to jump back into the function.
3250 | * the control of asynchronous call can be done outside of your code
3251 |
3252 | The most important feature in generators — we can get the next value in only when we really need it, not all the values at once. And in some situations it can be very convenient.
3253 |
3254 | **Source:** _stackoverflow.com_
3255 |
3256 | #### Q11: Explain what is hoisting in Javascript ⭐⭐⭐⭐
3257 | **Answer:**
3258 | Read Full Answer on 👉 FullStack.Cafe
3259 |
3260 | #### Q12: What will be the output of the following code? ⭐⭐⭐⭐
3261 | **Details:**
3262 | ```javascript
3263 | var output = (function(x) {
3264 | delete x;
3265 | return x;
3266 | })(0);
3267 |
3268 | console.log(output);
3269 | ```
3270 |
3271 | **Answer:**
3272 | Read Full Answer on 👉 FullStack.Cafe
3273 |
3274 | #### Q13: What will be the output of the following code? ⭐⭐⭐⭐
3275 | **Details:**
3276 | ```javascript
3277 | var Employee = {
3278 | company: 'xyz'
3279 | }
3280 | var emp1 = Object.create(Employee);
3281 | delete emp1.company
3282 | console.log(emp1.company);
3283 | ```
3284 |
3285 | **Answer:**
3286 | Read Full Answer on 👉 FullStack.Cafe
3287 |
3288 | #### Q14: Explain the Prototype Design Pattern ⭐⭐⭐⭐
3289 | **Answer:**
3290 | Read Full Answer on 👉 FullStack.Cafe
3291 |
3292 | #### Q15: What is the Temporal Dead Zone in ES6? ⭐⭐⭐⭐
3293 | **Answer:**
3294 | Read Full Answer on 👉 FullStack.Cafe
3295 |
3296 | #### Q16: Can you describe the main difference between a `.forEach` loop and a `.map()` loop and why you would pick one versus the other? ⭐⭐⭐⭐
3297 | **Answer:**
3298 | Read Full Answer on 👉 FullStack.Cafe
3299 |
3300 | #### Q17: What's the difference between a variable that is: `null`, `undefined` or undeclared? How would you go about checking for any of these states? ⭐⭐⭐⭐
3301 | **Answer:**
3302 | Read Full Answer on 👉 FullStack.Cafe
3303 |
3304 | #### Q18: Describe the Revealing Module Pattern design pattern ⭐⭐⭐⭐⭐
3305 | **Answer:**
3306 | Read Full Answer on 👉 FullStack.Cafe
3307 |
3308 | #### Q19: What's the difference between ES6 Map and WeakMap? ⭐⭐⭐⭐⭐
3309 | **Answer:**
3310 | Read Full Answer on 👉 FullStack.Cafe
3311 |
3312 | #### Q20: Is JavaScript a pass-by-reference or pass-by-value language? ⭐⭐⭐⭐⭐
3313 | **Answer:**
3314 | Read Full Answer on 👉 FullStack.Cafe
3315 |
3316 | #### Q21: How to "deep-freeze" object in JavaScript? ⭐⭐⭐⭐⭐
3317 | **Answer:**
3318 | Read Full Answer on 👉 FullStack.Cafe
3319 |
3320 | #### Q22: In JavaScript, why is the “this” operator inconsistent? ⭐⭐⭐⭐⭐
3321 | **Answer:**
3322 | Read Full Answer on 👉 FullStack.Cafe
3323 |
3324 | #### Q23: Compare Async/Await and Generators usage to achive same functionality ⭐⭐⭐⭐⭐
3325 | **Answer:**
3326 | Read Full Answer on 👉 FullStack.Cafe
3327 |
3328 | ## [[⬆]](#toc) 26 Top Angular 8 Interview Questions To Learn in 2019
3329 | > Originally published on 👉 26 Top Angular 8 Interview Questions To Learn in 2019 | FullStack.Cafe
3330 |
3331 | #### Q1: Explain the difference between `Promise` and `Observable` in Angular? ⭐⭐⭐
3332 | **Answer:**
3333 | **Promises**:
3334 | - return a single value
3335 | - not cancellable
3336 | - more readable code with try/catch and async/await
3337 |
3338 | **Observables**:
3339 | - work with multiple values over time
3340 | - cancellable
3341 | - support map, filter, reduce and similar operators
3342 | - use Reactive Extensions (RxJS)
3343 | - an array whose items arrive asynchronously over time
3344 |
3345 | **Source:** _stackoverflow.com_
3346 |
3347 | #### Q2: Why should `ngOnInit` be used, if we already have a `constructor`? ⭐⭐⭐
3348 | **Answer:**
3349 | * The `Constructor` is a default method of the class that is executed when the class is instantiated and ensures proper initialization of fields in the class and its subclasses.
3350 |
3351 | * `ngOnInit` is a life cycle hook called by Angular2 to indicate that Angular is done creating the component.
3352 |
3353 | Mostly we use `ngOnInit` for all the initialization/declaration and avoid stuff to work in the constructor. The constructor should only be used to initialize class members but shouldn't do actual "work". So you should use `constructor()` to setup Dependency Injection and not much else. ngOnInit() is better place to "start" - it's where/when components' bindings are resolved.
3354 |
3355 | **Source:** _medium.com_
3356 |
3357 | #### Q3: What is AOT? ⭐⭐⭐
3358 | **Answer:**
3359 | The Angular Ahead-of-Time compiler pre-compiles application components and their templates during the build process.
3360 | Apps compiled with AOT launch faster for several reasons.
3361 | * Application components execute immediately, without client-side compilation.
3362 | * Templates are embedded as code within their components so there is no client-side request for template files.
3363 | * You don't download the Angular compiler, which is pretty big on its own.
3364 | * The compiler discards unused Angular directives that a tree-shaking tool can then exclude.
3365 |
3366 | **Source:** _stackoverflow.com_
3367 |
3368 | #### Q4: What is the use of codelyzer? ⭐⭐⭐
3369 | **Answer:**
3370 | All enterprise applications follows a set of coding conventions and guidelines to maintain code in better way. **Codelyzer** is an open source tool to run and check whether the pre-defined coding guidelines has been followed or not. Codelyzer does only static code analysis for angular and typescript project.
3371 |
3372 | Codelyzer runs on top of tslint and its coding conventions are usually defined in tslint.json file. Codelyzer can be run via angular cli or npm directly. Editors like Visual Studio Code and Atom also supports codelyzer just by doing a basic settings.
3373 |
3374 | **Source:** _pankajagarwal.in_
3375 |
3376 | #### Q5: What is the purpose of Wildcard route? ⭐⭐⭐
3377 | **Answer:**
3378 | If the URL doesn't match any predefined routes then it causes the router to throw an error and crash the app. In this case, you can use wildcard route. A wildcard route has a path consisting of two asterisks to match every URL.
3379 |
3380 | For example, you can define PageNotFoundComponent for wildcard route as below
3381 | ```javascript
3382 | { path: '**', component: PageNotFoundComponent }
3383 | ```
3384 |
3385 | **Source:** _github.com/sudheerj_
3386 |
3387 | #### Q6: What are custom elements? ⭐⭐⭐
3388 | **Answer:**
3389 | Custom elements (or Web Components) are a Web Platform feature which extends HTML by allowing you to define a tag whose content is created and controlled by JavaScript code. The browser maintains a `CustomElementRegistry` of defined custom elements, which maps an instantiable JavaScript class to an HTML tag. Currently this feature is supported by Chrome, Firefox, Opera, and Safari, and available in other browsers through polyfills.
3390 |
3391 | **Source:** _github.com/sudheerj_
3392 |
3393 | #### Q7: What are the utility functions provided by RxJS? ⭐⭐⭐
3394 | **Answer:**
3395 | The RxJS library also provides below utility functions for creating and working with observables.
3396 | 1. Converting existing code for async operations into observables
3397 | 2. Iterating through the values in a stream
3398 | 3. Mapping values to different types
3399 | 4. Filtering streams
3400 | 5. Composing multiple streams
3401 |
3402 | **Source:** _github.com/sudheerj_
3403 |
3404 | #### Q8: What is subscribing? ⭐⭐⭐
3405 | **Answer:**
3406 | An Observable instance begins publishing values only when someone subscribes to it. So you need to subscribe by calling the **subscribe()** method of the instance, passing an observer object to receive the notifications.
3407 |
3408 | Let's take an example of creating and subscribing to a simple observable, with an observer that logs the received message to the console.
3409 | ```javascript
3410 | Creates an observable sequence of 5 integers, starting from 1
3411 | const source = range(1, 5);
3412 |
3413 | // Create observer object
3414 | const myObserver = {
3415 | next: x => console.log('Observer got a next value: ' + x),
3416 | error: err => console.error('Observer got an error: ' + err),
3417 | complete: () => console.log('Observer got a complete notification'),
3418 | };
3419 |
3420 | // Execute with the observer object and Prints out each item
3421 | myObservable.subscribe(myObserver);
3422 | // => Observer got a next value: 1
3423 | // => Observer got a next value: 2
3424 | // => Observer got a next value: 3
3425 | // => Observer got a next value: 4
3426 | // => Observer got a next value: 5
3427 | // => Observer got a complete notification
3428 | ```
3429 |
3430 | **Source:** _github.com/sudheerj_
3431 |
3432 | #### Q9: What's new in Angular 8? ⭐⭐⭐
3433 | **Answer:**
3434 | This release is mostly about Ivy and the possibility to give it a try, but it also includes a few features and breaking changes, namely:
3435 |
3436 | * **Differential loading** - with differential loading, two bundles are created when building for production: a bundle for modern browsers that support ES2015+ and a bundle for older browsers that only support the ES5 version of JavaScript
3437 | * **TypeScript 3.4** support
3438 | * **Ivy** - it is the new compiler/runtime of Angular. It will enable very cool features in the future, but it is currently focused on not breaking existing applications.
3439 | * **Bazel** support - it is a build tool developed and massively used by Google, as it can build pretty much any language.
3440 | * **Lazy-loading with import()** syntax
3441 |
3442 | ```js
3443 | // from
3444 | loadChildren: './admin/admin.module#AdminModule'
3445 | // to
3446 | loadChildren: () => import('./races/races.module').then(m => m.RacesModule)
3447 | ```
3448 |
3449 | * To help people migrating from AngularJS, a bunch of things have been added to the **location services** in Angular
3450 | * The **service worker registration** has a new option that allows to specify when the registration should take place.
3451 | * `@angular/http` has been removed from 8.0, after being replaced by `@angular/common/http` in 4.3 and officially deprecated in 5.0,
3452 |
3453 | **Source:** _blog.ninja-squad.com_
3454 |
3455 | #### Q10: Angular 8: What is Bazel? ⭐⭐⭐
3456 | **Answer:**
3457 | Google open sourced the software responsible for building most of its projects under the name **Bazel**. Bazel is a powerful tool which can keep track of the dependencies between different packages and build targets.
3458 |
3459 | Some of the features of Bazel are:
3460 |
3461 | * It has a smart algorithm for determining the build dependencies - based on the dependency graph of a project, Bazel determines which targets it can build in parallel
3462 | * Bazel is independent of the tech stack. We can build anything we want with it using the same interface. For example, there are plugins for Java, Go, TypeScript, JavaScript, and more
3463 |
3464 |
3465 | **Source:** _blog.mgechev.com_
3466 |
3467 | #### Q11: Angular 8: What is Angular Ivy? ⭐⭐⭐
3468 | **Answer:**
3469 | A big part of Angular is its compiler: it takes all your HTML and generates the necessary JS code. This compiler (and the runtime) has been completely rewritten over the last year, and this is what Ivy is about. The last rewrite was done in Angular 4.0.
3470 |
3471 | **Ivy** is a complete rewrite of the compiler (and runtime) in order to:
3472 |
3473 | * reach better build times (with a more incremental compilation)
3474 | * reach better build sizes (with a generated code more compatible with tree-shaking)
3475 | * unlock new potential features (metaprogramming or higher order components, lazy loading of component instead of modules, a new change detection system not based on zone.js…)
3476 |
3477 | **Source:** _blog.ninja-squad.com_
3478 |
3479 | #### Q12: Angular 8: Explain Lazy Loading in Angular 8? ⭐⭐⭐
3480 | **Answer:**
3481 | Lazy loading is one of the most useful concepts of Angular Routing and brings down the size of large files. This is done by lazily loading the files that are required _occasionally_.
3482 |
3483 | Angular 8 comes up with support for **dynamic imports** in our router configuration. This means that we use the import statement for lazy loading the module and this will be understood by the IDEs, webpack, etc.
3484 |
3485 | Angular 7:
3486 | ```js
3487 | {path: ‘user’, loadChildren: ‘./users/user.module#UserModule’}
3488 | ```
3489 | Angular 8:
3490 | ```js
3491 | {path: ‘user’, loadChildren: () => import(‘./users/user.module’).then(m => m.UserModule)};
3492 | ```
3493 |
3494 | New with Angular 8, `loadChildren` expects a function that uses the dynamic import syntax to import your lazy-loaded module only when it’s needed. As you can see, the dynamic import is promise-based and gives you access to the module, where the module’s class can be called.
3495 |
3496 | **Source:** _dev.to_
3497 |
3498 | #### Q13: How to detect a route change in Angular? ⭐⭐⭐⭐
3499 | **Answer:**
3500 | Read Full Answer on 👉 FullStack.Cafe
3501 |
3502 | #### Q14: Are there any pros/cons (especially performance-wise) in using local storage to replace cookie functionality? ⭐⭐⭐⭐
3503 | **Answer:**
3504 | Read Full Answer on 👉 FullStack.Cafe
3505 |
3506 | #### Q15: What is Zone in Angular? ⭐⭐⭐⭐
3507 | **Answer:**
3508 | Read Full Answer on 👉 FullStack.Cafe
3509 |
3510 | #### Q16: What does a just-in-time (JIT) compiler do (in general)? ⭐⭐⭐⭐
3511 | **Answer:**
3512 | Read Full Answer on 👉 FullStack.Cafe
3513 |
3514 | #### Q17: What is ngUpgrage? ⭐⭐⭐⭐
3515 | **Answer:**
3516 | Read Full Answer on 👉 FullStack.Cafe
3517 |
3518 | #### Q18: What is incremental DOM? How is it different from virtual DOM? ⭐⭐⭐⭐
3519 | **Answer:**
3520 | Read Full Answer on 👉 FullStack.Cafe
3521 |
3522 | #### Q19: Angular 8: Why we should use Bazel for Angular builds? ⭐⭐⭐⭐
3523 | **Answer:**
3524 | Read Full Answer on 👉 FullStack.Cafe
3525 |
3526 | #### Q20: Explain the purpose of Service Workers in Angular ⭐⭐⭐⭐
3527 | **Answer:**
3528 | Read Full Answer on 👉 FullStack.Cafe
3529 |
3530 | #### Q21: What is the Angular equivalent to an AngularJS "$watch"? ⭐⭐⭐⭐⭐
3531 | **Answer:**
3532 | Read Full Answer on 👉 FullStack.Cafe
3533 |
3534 | #### Q22: Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation. Explain the difference. ⭐⭐⭐⭐⭐
3535 | **Answer:**
3536 | Read Full Answer on 👉 FullStack.Cafe
3537 |
3538 | #### Q23: Why did the Google team go with incremental DOM instead of virtual DOM? ⭐⭐⭐⭐⭐
3539 | **Answer:**
3540 | Read Full Answer on 👉 FullStack.Cafe
3541 |
3542 | #### Q24: Why Incremental DOM is Tree Shakable? ⭐⭐⭐⭐⭐
3543 | **Answer:**
3544 | Read Full Answer on 👉 FullStack.Cafe
3545 |
3546 | #### Q25: Angular 8: How does Ivy affect the (Re)build time? ⭐⭐⭐⭐⭐
3547 | **Answer:**
3548 | Read Full Answer on 👉 FullStack.Cafe
3549 |
3550 | #### Q26: Angular 8: What are some changes in Location module? ⭐⭐⭐⭐⭐
3551 | **Answer:**
3552 | Read Full Answer on 👉 FullStack.Cafe
3553 |
3554 | ## [[⬆]](#toc) 29 Essential Blockchain Interview Questions You Will Suck On
3555 | > Originally published on 👉 29 Essential Blockchain Interview Questions You Will Suck On | FullStack.Cafe
3556 |
3557 | #### Q1: What is blockchain? ⭐
3558 | **Answer:**
3559 | **Blockchain** is a secure distributed ledger (data structure or database) that maintains a continuously growing list of ordered records, called “blocks”, that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.
3560 |
3561 | By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".
3562 |
3563 | Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority.
3564 |
3565 | **Source:** _en.wikipedia.org_
3566 |
3567 | #### Q2: Explain the common structure of blockchains ⭐⭐
3568 | **Answer:**
3569 | Blockchains are composed of three core parts:
3570 | * **Block**: A list of transactions recorded into a ledger over a given period. The size, period, and triggering event for blocks is different for every blockchain.
3571 | * **Chain**: A hash that links one block to another, mathematically “chaining” them together.
3572 | * **Network**: The network is composed of “full nodes.” Think of them as the computer running an algorithm that is securing the network. Each node contains a complete record of all the transactions that were ever recorded in that blockchain.
3573 |
3574 | **Source:** _dummies.com_
3575 |
3576 | #### Q3: What is the blockchain data structure? ⭐⭐
3577 | **Answer:**
3578 | Basically **the blockchain data structure** is explained as a back-linked record of blocks of transactions, which is ordered. It can be saved as a file or in a plain database. Each block can be recognized by a hash, created utilizing the SHA256 cryptographic hash algorithm on the header of the block. Each block mentions a former block, also identified as the parent block, in the “previous block hash” field, in the block header.
3579 |
3580 |
3581 |
3582 |
3583 |
3584 |
3585 | **Source:** _cryptoticker.io_
3586 |
3587 | #### Q4: What is the Genesis Block? ⭐⭐
3588 | **Answer:**
3589 | The **first block in any blockchain **is termed the **genesis block**. If you start at any block and follow the chain backwards chronologically, you will arrive at the genesis block. The genesis block is statically encoded within the client software, that it cannot be changed. Every node can identify the genesis block’s hash and structure, the fixed time of creation, and the single transactions within. Thus every node has a secure “root” from which is possible to build a trusted blockchain on.
3590 |
3591 | **Source:** _linkedin.com_
3592 |
3593 | #### Q5: What is the purpose of a blockchain node? ⭐⭐
3594 | **Answer:**
3595 | A blockchain exists out of blocks of data. These blocks of data are stored on nodes (compare it to small servers). **Nodes** can be any kind of device (mostly computers, laptops or even bigger servers). Nodes form the infrastructure of a blockchain.
3596 |
3597 | All nodes on a blockchain are connected to each other and they constantly exchange the latest blockchain data with each other so all nodes stay up to date. They store, spread and preserve the blockchain data, so theoretically a blockchain exists on nodes.
3598 |
3599 | A **full node** is basically a device (like a computer) that contains a full copy of the transaction history of the blockchain.
3600 |
3601 | **Source:** _lisk.io_
3602 |
3603 | #### Q6: What is proof-of-work? ⭐⭐
3604 | **Answer:**
3605 | A **proof of work** is a piece of data which is difficult (costly, time-consuming) to produce but easy for others to verify and which satisfies certain requirements. Producing a proof of work can be a random process with low probability so that a lot of trial and error is required on average before a valid proof of work is generated. Difficulty is a measure of how difficult it is to find a hash below a given target.
3606 |
3607 | **Source:** _en.bitcoin.it_
3608 |
3609 | #### Q7: What is deterministic behavior? ⭐⭐
3610 | **Answer:**
3611 | If A + B = C, then no matter what the circumstances, A+B will always be equal to C. That is called deterministic behavior.
3612 |
3613 | Hash functions are deterministic, meaning A’s hash will always be H(A).
3614 |
3615 | **Source:** _blockgeeks.com_
3616 |
3617 | #### Q8: Why does Blockchain need coins or tokens? ⭐⭐
3618 | **Answer:**
3619 | _Tokens/Coins are used as a medium of exchange between the states_. They are digital assets built in to perform a specific function within a blockchain.
3620 |
3621 | When someone does a transaction, there is a _change of state_, and coins are moved from one address to another address. Apart from that, transactions contain some additional data; this data can be mutated through the change of state. For this reason, blockchains need coins or tokens to incentivize the participants to join their networks.
3622 |
3623 | **Source:** _mindmajix.com_
3624 |
3625 | #### Q9: What is Merkle Trees? ⭐⭐⭐
3626 | **Answer:**
3627 | Merkle trees are a fundamental part of blockchain technology. A merkle tree is a structure that allows for efficient and secure verification of content in a large body of data.
3628 |
3629 | A Merkle tree summarizes all the transactions in a block by producing a digital fingerprint of the entire set of transactions, thereby enabling a user to verify whether or not a transaction is included in a block.
3630 |
3631 | Merkle trees are created by repeatedly hashing pairs of nodes until there is only one hash left (this hash is called the Root Hash, or the Merkle Root). They are constructed from the bottom up, from hashes of individual transactions (known as Transaction IDs). Hashing is usually conducted using the SHA-2 cryptographic hash function, though other functions can also be used.
3632 |
3633 |
3634 |
3635 |
3636 |
3637 |
3638 | **Source:** _hackernoon.com_
3639 |
3640 | #### Q10: What are some advantages of using Merke Trees? ⭐⭐⭐
3641 | **Answer:**
3642 | Using a Merkle tree can significantly reduce the amount of data that a trusted authority has to maintain for verification purposes. It separates the validation of the data from the data itself.
3643 |
3644 | Merkle trees have three major benefits:
3645 |
3646 | 1. They provide a means to prove the integrity and validity of data
3647 | 2. They require little memory or disk space as the proofs are computationally easy and fast
3648 | 3. Their proofs and management only require tiny amounts of information to be transmitted across networks
3649 |
3650 | The ability to prove that a log is complete and consistent is essential to blockchain technology and the general ledger concept. Merkle trees help verify that later versions of a log include everything from an earlier version and that all data is recorded and presented in chronological order.
3651 |
3652 | **Source:** _hackernoon.com_
3653 |
3654 | #### Q11: Explain what do nodes do? ⭐⭐⭐
3655 | **Answer:**
3656 | When a miner attempts to add a new block of transactions to the blockchain, it broadcasts the block to all the nodes on the network. Based on the block’s legitimacy (validity of signature and transactions), nodes can accept or reject the block. When a node accepts a new block of transactions, it saves and stores it on top of the rest of the blocks it already has stored. In short, here is what nodes do:
3657 | * Nodes **check** if a block of transactions is valid and **accept** or **reject** it.
3658 | * Nodes **save and store blocks of transactions** (storing blockchain transaction history).
3659 | * Nodes **broadcast and spread** this transaction history to other nodes that may need to synchronize with the blockchain (need to be updated on transaction history).
3660 |
3661 | **Source:** _medium.com_
3662 |
3663 | #### Q12: Why is the blockchain immutable? ⭐⭐⭐
3664 | **Answer:**
3665 | **Altering a single block requires a new signature for every other block that comes after it all the way to the end of the chain**. This is considered to be near impossible. Why?
3666 |
3667 | Let’s say a corrupt miner has altered a block of transactions and is now trying to calculate new signatures for the subsequent blocks in order to have the rest of the network accept his change. The problem for him is, the rest of the network is also calculating new signatures for new blocks. The corrupt miner will have to calculate new signatures for these blocks too as they are being added to the end of the chain. After all, he needs to keep all of the blocks linked, including the new ones constantly being added. Unless the miner has more computational power than the rest of the network combined, he will never catch up with the rest of the network finding signatures.
3668 |
3669 | Millions of users are mining on the blockchain, and therefore it can be assumed that a single bad actor or entity on the network will never have more computational power than the rest of the network combined, meaning the network will never accept any changes on the blockchain, making the blockchain immutable.
3670 |
3671 | **Source:** _medium.com_
3672 |
3673 | #### Q13: What is mining difficulty? ⭐⭐⭐
3674 | **Answer:**
3675 | **Mining difficulty** is the degree that determines how hard it is for miners in terms of hashing power (and thus also time) to find an eligible hash aka signature for their block (a block of transactions needs an eligible hash to be verified and added to the blockchain). On the Bitcoin blockchain, miners try to find an eligible hash by hashing random numbers.
3676 |
3677 | A block of transactions will only be accepted by the rest of the network if it has a signature (hash) that meets certain requirements (in example of Bitcoin, the signature needs to start with a certain number of zeroes). In order to find this signature, miners are spending computational power (hashing power) to perform a set of pre-determined operations on random numbers untill they find a number that leads to an output number that meets the requirements.
3678 |
3679 | Finding an output that starts with only one zero is much easier (generally more common) than finding an output number that starts with five consecutive zeroes (this is pretty rare so it would take much more time to find a number that leads to such output).
3680 |
3681 | For example block 100 (back in 2009) only required a signature that started with eight consecutive zeroes, whereas the last recent block (block 542865) needed a signature that started with at least 18 consecutive zeroes.
3682 |
3683 | **Source:** _medium.com_
3684 |
3685 | #### Q14: Explain why there is a fixed supply of bitcoins? ⭐⭐⭐
3686 | **Answer:**
3687 | There is a fixed supply of bitcoins. There will never be more than 21 million bitcoins. Bitcoins are created each time a user discovers a **new block**. The rate of block creation is adjusted every 2016 blocks to aim for a constant two week adjustment period (equivalent to 6 per hour).
3688 |
3689 | The number of bitcoins generated per block is set to decrease geometrically, with a 50% reduction every 210,000 blocks, or approximately four years. The result is that the number of bitcoins in existence will not exceed slightly less than 21 million.
3690 |
3691 |
3692 |
3693 |
3694 |
3695 |
3696 |
3697 | **Source:** _en.bitcoin.it_
3698 |
3699 | #### Q15: What is DApp or Decentralised Application? ⭐⭐⭐
3700 | **Answer:**
3701 | A **decentralized application (DApp, dApp, Dapp, or dapp)** is a computer application that **runs on a distributed computing system**.
3702 |
3703 | Decentralized applications don‘t necessarily need to run on top of a blockchain network. Tor, BitTorrent, Popcorn Time, BitMessage, are examples for decentralized applications that run on a P2P network, but not on a blockchain – which is a special kind of P2P network.
3704 |
3705 | DApps have been mostly popularized by distributed ledger technologies (DLT), namely the Ethereum Blockchain, where DApps are often referred to as smart contracts. Its backend code runs on a decentralized peer-to-peer network, and all records of the applicationʼs operation are stored on a blockchain. In most cases, the entire code base is Open Source.
3706 |
3707 |
3708 | **Source:** _blockchainhub.net_
3709 |
3710 | #### Q16: What is a trapdoor function, and why is it needed in blockchain development? ⭐⭐⭐
3711 | **Answer:**
3712 | A **trapdoor** function is a function that is easy to compute in one direction but difficult to compute in the opposite direction unless you have special information. Trapdoor functions are essential for public key encryption—that’s why they are commonly used in blockchain development to represent the ideas of addresses and private keys.
3713 |
3714 | **Source:** _toptal.com_
3715 |
3716 | #### Q17: Explain why a blockchain needs tokens to operate ⭐⭐⭐
3717 | **Answer:**
3718 | **Coins/tokens** are used to implement _changes between states_. When somebody does a transaction, this is a change of state, and coins are moved from one address to another. Apart from that, transactions can contain additional data, and a change of state is used to mutate data—the only way to do this in an immutable-by-definition blockchain.
3719 |
3720 | Technically, a blockchain doesn’t need coins for its essential operations, but without them, some other way needs to be introduced to manage states of the chain and to verify transactions.
3721 |
3722 | **Source:** _toptal.com_
3723 |
3724 | #### Q18: How do verifiers check if a block is valid? ⭐⭐⭐
3725 | **Answer:**
3726 | Every full node on the network does block verification. When a new block is announced, every node that receives it does a list of checks. The two most important checks are of **proof of work** (if a block provides enough work to be included into chain) and of the **validity of all transactions** (each transaction must be valid).
3727 |
3728 | **Source:** _toptal.com_
3729 |
3730 | #### Q19: What is RSA algorithm? ⭐⭐⭐
3731 | **Answer:**
3732 | **RSA (Rivest–Shamir–Adleman)** is an algorithm used by modern computers to encrypt and decrypt messages. It is an _asymmetric_ cryptographic algorithm. Asymmetric means that there are two different keys. This is also called public key cryptography, because one of the keys can be given to anyone. The other key must be kept private. The algorithm is based on the fact that finding the factors of a large composite number is difficult.
3733 |
3734 | RSA involves a **public** key and **private** key. The public key can be known to everyone; it is used to encrypt messages. Messages encrypted using the public key can only be decrypted with the private key.
3735 |
3736 | **Source:** _simple.wikipedia.org_
3737 |
3738 | #### Q20: What is a smart contract? ⭐⭐⭐
3739 | **Answer:**
3740 | A smart contract is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract. Smart contracts allow the performance of credible transactions without third parties. These transactions are trackable and irreversible.
3741 |
3742 | The aim of smart contracts is to provide security that is superior to traditional contract law and to reduce other transaction costs associated with contracting. Various cryptocurrencies have implemented types of smart contracts.
3743 |
3744 | **Source:** _en.wikipedia.org_
3745 |
3746 | #### Q21: What is a 51% attack? ⭐⭐⭐⭐
3747 | **Answer:**
3748 | Read Full Answer on 👉 FullStack.Cafe
3749 |
3750 | #### Q22: What is a stealth address? ⭐⭐⭐⭐
3751 | **Answer:**
3752 | Read Full Answer on 👉 FullStack.Cafe
3753 |
3754 | #### Q23: Explain what is target hash? ⭐⭐⭐⭐
3755 | **Answer:**
3756 | Read Full Answer on 👉 FullStack.Cafe
3757 |
3758 | #### Q24: What Is a Proof of Stake? ⭐⭐⭐⭐
3759 | **Answer:**
3760 | Read Full Answer on 👉 FullStack.Cafe
3761 |
3762 | #### Q25: What is the difference between PoW and PoS? ⭐⭐⭐⭐
3763 | **Answer:**
3764 | Read Full Answer on 👉 FullStack.Cafe
3765 |
3766 | #### Q26: What is off-chain transaction? ⭐⭐⭐⭐
3767 | **Answer:**
3768 | Read Full Answer on 👉 FullStack.Cafe
3769 |
3770 | #### Q27: Why is Git not considered a “block chain”? ⭐⭐⭐⭐⭐
3771 | **Answer:**
3772 | Read Full Answer on 👉 FullStack.Cafe
3773 |
3774 | #### Q28: What are miners really solving? ⭐⭐⭐⭐⭐
3775 | **Details:**
3776 | As with mining, what are miners really solving? I read they are solving hashes, but what does that really mean.
3777 |
3778 | **Answer:**
3779 | Read Full Answer on 👉 FullStack.Cafe
3780 |
3781 | #### Q29: Is it possible to brute force bitcoin address creation in order to steal money? ⭐⭐⭐⭐⭐
3782 | **Answer:**
3783 | Read Full Answer on 👉 FullStack.Cafe
3784 |
3785 | ## [[⬆]](#toc) 30 Best MongoDB Interview Questions and Answers (2018 Update)
3786 | > Originally published on 👉 30 Best MongoDB Interview Questions and Answers (2018 Update) | FullStack.Cafe
3787 |
3788 | #### Q1: Explain what is MongoDB? ⭐
3789 | **Answer:**
3790 | MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling.
3791 | It's Key Features are:
3792 | * Document Oriented and NoSQL database.
3793 | * Supports Aggregation
3794 | * Uses BSON format
3795 | * Sharding (Helps in Horizontal Scalability)
3796 | * Supports Ad Hoc Queries
3797 | * Schema Less
3798 | * Capped Collection
3799 | * Indexing (Any field in MongoDB can be indexed)
3800 | * MongoDB Replica Set (Provides high availability)
3801 | * Supports Multiple Storage Engines
3802 |
3803 | **Source:** _mongodb.com_
3804 |
3805 | #### Q2: What Is Replication In MongoDB? ⭐⭐
3806 | **Answer:**
3807 | **Replication** is the process of synchronizing data across multiple servers. Replication provides redundancy and increases data availability. With multiple copies of data on different database servers, replication protects a database from the loss of a single server. Replication also allows you to recover from hardware failure and service interruptions.
3808 |
3809 | **Source:** _interviewbubble.com_
3810 |
3811 | #### Q3: How is data stored in MongoDB? ⭐⭐
3812 | **Answer:**
3813 | Data in MongoDB is stored in BSON documents – JSON-style data structures. Documents contain one or more fields, and each field contains a value of a specific data type, including arrays, binary data and sub-documents. Documents that tend to share a similar structure are organized as collections. It may be helpful to think of documents as analogous to rows in a relational database, fields as similar to columns, and collections as similar to tables.
3814 |
3815 | The advantages of using documents are:
3816 |
3817 | * Documents (i.e. objects) correspond to native data types in many programming languages.
3818 | * Embedded documents and arrays reduce need for expensive joins.
3819 | * Dynamic schema supports fluent polymorphism.
3820 |
3821 | **Source:** _mongodb.com_
3822 |
3823 | #### Q4: What are Indexes in MongoDB? ⭐⭐
3824 | **Answer:**
3825 | Indexes support the efficient execution of queries in MongoDB. Without indexes, MongoDB must perform a collection scan, i.e. scan every document in a collection, to select those documents that match the query statement. If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect.
3826 |
3827 | **Source:** _tutorialspoint.com_
3828 |
3829 | #### Q5: Can you create an index on an array field in MongoDB? If yes, what happens in this case? ⭐⭐
3830 | **Answer:**
3831 | Yes. An array field can be indexed in MongoDB. In this case, MongoDB would index each value of the array so you can query for individual items:
3832 |
3833 | ```js
3834 | > db.col1.save({'colors': ['red','blue']})
3835 | > db.col1.ensureIndex({'colors':1})
3836 |
3837 | > db.col1.find({'colors': 'red'})
3838 | { "_id" : ObjectId("4ccc78f97cf9bdc2a2e54ee9"), "colors" : [ "red", "blue" ] }
3839 | > db.col1.find({'colors': 'blue'})
3840 | { "_id" : ObjectId("4ccc78f97cf9bdc2a2e54ee9"), "colors" : [ "red", "blue" ] }
3841 | ```
3842 |
3843 | **Source:** _stackoverflow.com_
3844 |
3845 | #### Q6: What is Aggregation in MongoDB? ⭐⭐⭐
3846 | **Answer:**
3847 | *Aggregations* operations process data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result. MongoDB provides three ways to perform aggregation:
3848 | * the aggregation pipeline,
3849 | * the map-reduce function,
3850 | * and single purpose aggregation methods and commands.
3851 |
3852 | **Source:** _tutorialspoint.com_
3853 |
3854 | #### Q7: How to query MongoDB with %like%? ⭐⭐⭐
3855 | **Details:**
3856 | I want to query something as SQL's like query:
3857 |
3858 | ```sql
3859 | select *
3860 | from users
3861 | where name like '%m%'
3862 | ```
3863 | How to do the same in MongoDB?
3864 |
3865 | **Answer:**
3866 | ```js
3867 | db.users.find({name: /a/}) //like '%a%'
3868 | db.users.find({name: /^pa/}) //like 'pa%'
3869 | db.users.find({name: /ro$/}) //like '%ro'
3870 | ```
3871 | Or using Mongoose:
3872 | ```js
3873 | db.users.find({'name': {'$regex': 'sometext'}})
3874 | ```
3875 |
3876 | **Source:** _stackoverflow.com_
3877 |
3878 | #### Q8: How do I perform the SQL JOIN equivalent in MongoDB? ⭐⭐⭐
3879 | **Answer:**
3880 | Mongo is not a relational database, and the devs are being careful to recommend specific use cases for $lookup, but at least as of 3.2 doing join is now possible with MongoDB. The new $lookup operator added to the aggregation pipeline is essentially identical to a left outer join:
3881 |
3882 | ```js
3883 | {
3884 | $lookup:
3885 | {
3886 | from: ,
3887 | localField: ,
3888 | foreignField: ,
3889 | as:
3890 | }
3891 | }
3892 | ```
3893 |
3894 | **Source:** _stackoverflow.com_
3895 |
3896 | #### Q9: What is the difference b/w MongoDB and CouchDB? ⭐⭐⭐
3897 | **Answer:**
3898 | MongoDB and CouchDB both are the great example of open source NoSQL database. Both are document oriented databases. Although both stores data but there is a lot of difference between them in terms of implementation of their data models, interfaces, object storage and replication methods etc.
3899 |
3900 | **Source:** _medium.com/@hub4tech_
3901 |
3902 | #### Q10: What are NoSQL databases? What are the different types of NoSQL databases? ⭐⭐⭐
3903 | **Answer:**
3904 | A NoSQL database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases (like SQL, Oracle, etc.).
3905 |
3906 | Types of NoSQL databases:
3907 |
3908 | * Document Oriented
3909 | * Key Value
3910 | * Graph
3911 | * Column Oriented
3912 |
3913 | **Source:** _interviewbubble.com_
3914 |
3915 | #### Q11: Explain the structure of ObjectID in MongoDB ⭐⭐⭐
3916 | **Answer:**
3917 | **ObjectIds** are small, likely unique, fast to generate, and ordered. ObjectId values consist of 12 bytes, where the first four bytes are a timestamp that reflect the ObjectId’s creation. Specifically:
3918 |
3919 | * a 4-byte value representing the seconds since the Unix epoch,
3920 | * a 5-byte random value, and
3921 | * a 3-byte counter, starting with a random value.
3922 | In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. If an inserted document omits the _id field, the MongoDB driver automatically generates an ObjectId for the _id field.
3923 |
3924 | **Source:** _mongodb.com_
3925 |
3926 | #### Q12: What is a covered query in MongoDB? ⭐⭐⭐
3927 | **Answer:**
3928 | A covered query is the one in which:
3929 |
3930 | * fields used in the query are part of an index used in the query, and
3931 | * the fields returned in the results are in the same index
3932 |
3933 | **Source:** _tutorialspoint.com_
3934 |
3935 | #### Q13: Find objects between two dates MongoDB ⭐⭐⭐
3936 | **Answer:**
3937 | ```js
3938 | db.CollectionName.find({"whenCreated": {
3939 | '$gte': ISODate("2018-03-06T13:10:40.294Z"),
3940 | '$lt': ISODate("2018-05-06T13:10:40.294Z")
3941 | }});
3942 | ```
3943 |
3944 | **Source:** _stackoverflow.com_
3945 |
3946 | #### Q14: What is oplog? ⭐⭐⭐
3947 | **Answer:**
3948 | The *oplog* (operations log) is a special capped collection that keeps a rolling record of all operations that modify the data stored in your databases. MongoDB applies database operations on the primary and then records the operations on the primary’s oplog. The secondary members then copy and apply these operations in an asynchronous process.
3949 |
3950 | **Source:** _tutorialspoint.com_
3951 |
3952 | #### Q15: Does MongoDB support ACID transaction management and locking functionalities? ⭐⭐⭐
3953 | **Answer:**
3954 | ACID stands that any update is:
3955 | * **Atomic**: it either fully completes or it does not
3956 | * **Consistent**: no reader will see a "partially applied" update
3957 | * **Isolated**: no reader will see a "dirty" read
3958 | * **Durable**: (with the appropriate write concern)
3959 |
3960 | Historically MongoDB does not support default multi-document ACID transactions (multiple-document updates that can be rolled back and are ACID-compliant). However, MongoDB provides atomic operation on a single document. MongoDB 4.0 **will add support for multi-document transactions**, making it the only database to combine the speed, flexibility, and power of the document model with ACID data integrity guarantees.
3961 |
3962 | **Source:** _tutorialspoint.com_
3963 |
3964 | #### Q16: What is Sharding in MongoDB? Explain. ⭐⭐⭐
3965 | **Answer:**
3966 | *Sharding* is a method for storing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.
3967 |
3968 | **Source:** _tutorialspoint.com_
3969 |
3970 | #### Q17: Should I normalize my data before storing it in MongoDB? ⭐⭐⭐
3971 | **Answer:**
3972 | It depends from your goals. Normalization will provide an _update efficient data representation_. Denormalization will make data _reading efficient_.
3973 |
3974 | In general, use embedded data models (denormalization) when:
3975 |
3976 | * you have “contains” relationships between entities.
3977 | * you have one-to-many relationships between entities. In these relationships the “many” or child documents always appear with or are viewed in the context of the “one” or parent documents.
3978 |
3979 | In general, use normalized data models:
3980 |
3981 | * when embedding would result in duplication of data but would not provide sufficient read performance advantages to outweigh the implications of the duplication.
3982 | * to represent more complex many-to-many relationships.
3983 | * to model large hierarchical data sets.
3984 |
3985 | Also normalizing your data like you would with a relational database is usually not a good idea in MongoDB. Normalization in relational databases is only feasible under the premise that JOINs between tables are relatively cheap. The $lookup aggregation operator provides some limited JOIN functionality, but it doesn't work with sharded collections. So joins often need to be emulated by the application through multiple subsequent database queries, which is very slow (see question MongoDB and JOINs for more information).
3986 |
3987 | **Source:** _stackoverflow.com_
3988 |
3989 | #### Q18: How does MongoDB provide concurrency? ⭐⭐⭐⭐
3990 | **Answer:**
3991 | Read Full Answer on 👉 FullStack.Cafe
3992 |
3993 | #### Q19: What are Primary and Secondary Replica sets? ⭐⭐⭐⭐
3994 | **Answer:**
3995 | Read Full Answer on 👉 FullStack.Cafe
3996 |
3997 | #### Q20: How does Journaling work in MongoDB? ⭐⭐⭐⭐
3998 | **Answer:**
3999 | Read Full Answer on 👉 FullStack.Cafe
4000 |
4001 | #### Q21: When to Redis or MongoDB? ⭐⭐⭐⭐
4002 | **Answer:**
4003 | Read Full Answer on 👉 FullStack.Cafe
4004 |
4005 | #### Q22: MongoDB relationships. What to use - embed or reference? ⭐⭐⭐⭐
4006 | **Details:**
4007 | I want to design a question structure with some comments, but I don't know which relationship to use for comments: embed or reference? Explain me pros and cons of both solutions?
4008 |
4009 | **Answer:**
4010 | Read Full Answer on 👉 FullStack.Cafe
4011 |
4012 | #### Q23: Is MongoDB schema-less? ⭐⭐⭐⭐
4013 | **Answer:**
4014 | Read Full Answer on 👉 FullStack.Cafe
4015 |
4016 | #### Q24: How does MongoDB ensure high availability? ⭐⭐⭐⭐
4017 | **Answer:**
4018 | Read Full Answer on 👉 FullStack.Cafe
4019 |
4020 | #### Q25: How to check if a field contains a substring? ⭐⭐⭐⭐
4021 | **Answer:**
4022 | Read Full Answer on 👉 FullStack.Cafe
4023 |
4024 | #### Q26: What are alternatives to MongoDB? ⭐⭐⭐⭐
4025 | **Answer:**
4026 | Read Full Answer on 👉 FullStack.Cafe
4027 |
4028 | #### Q27: How to find document with array that contains a specific value? ⭐⭐⭐⭐⭐
4029 | **Details:**
4030 | You have this schema:
4031 | ```js
4032 | person = {
4033 | name : String,
4034 | favoriteFoods : Array
4035 | }
4036 | ```
4037 | where the `favoriteFoods` array is populated with strings. How can I find all persons that have `sushi` as their favorite food using MongoDB?
4038 |
4039 | **Answer:**
4040 | Read Full Answer on 👉 FullStack.Cafe
4041 |
4042 | #### Q28: Is it possible to update MongoDB field using value of another field? ⭐⭐⭐⭐⭐
4043 | **Details:**
4044 | In SQL we will use:
4045 | ```sql
4046 | UPDATE Person SET Name = FirstName + ' ' + LastName
4047 | ```
4048 | Is it possible with MongoDB?
4049 |
4050 | **Answer:**
4051 | Read Full Answer on 👉 FullStack.Cafe
4052 |
4053 | #### Q29: Explain what is horizontal scalability? ⭐⭐⭐⭐⭐
4054 | **Answer:**
4055 | Read Full Answer on 👉 FullStack.Cafe
4056 |
4057 | #### Q30: What are the differences between MongoDB and MySQL? ⭐⭐⭐⭐⭐
4058 | **Answer:**
4059 | Read Full Answer on 👉 FullStack.Cafe
4060 |
4061 | ## [[⬆]](#toc) 30 Docker Interview Questions and Answers in 2019
4062 | > Originally published on 👉 30 Docker Interview Questions and Answers in 2019 | FullStack.Cafe
4063 |
4064 | #### Q1: What is the need for DevOps? ⭐
4065 | **Answer:**
4066 | Nowadays instead of releasing big sets of features, companies are trying to see if small features can be transported to their customers through a series of release trains. This has many advantages like quick feedback from customers, better quality of software etc. which in turn leads to high customer satisfaction. To achieve this, companies are required to:
4067 |
4068 | 1. Increase deployment frequency
4069 | 2. Lower failure rate of new releases
4070 | 3. Shortened lead time between fixes
4071 | 4. Faster mean time to recovery in the event of new release crashing
4072 |
4073 | DevOps fulfills all these requirements and helps in achieving seamless software delivery.
4074 |
4075 | **Source:** _edureka.co_
4076 |
4077 | #### Q2: What are the advantages of DevOps? ⭐⭐
4078 | **Answer:**
4079 | Technical benefits:
4080 |
4081 | * Continuous software delivery
4082 | * Less complex problems to fix
4083 | * Faster resolution of problems
4084 |
4085 | Business benefits:
4086 |
4087 | * Faster delivery of features
4088 | * More stable operating environments
4089 | * More time available to add value (rather than fix/maintain)
4090 |
4091 | **Source:** _edureka.co_
4092 |
4093 | #### Q3: What is the function of CI (Continuous Integration) server? ⭐⭐
4094 | **Answer:**
4095 | CI server function is to continuously integrate all changes being made and committed to repository by different developers and check for compile errors. It needs to build code several times a day, preferably after every commit so it can detect which commit made the breakage if the breakage happens.
4096 |
4097 | **Source:** _linoxide.com_
4098 |
4099 | #### Q4: What is Docker? ⭐
4100 | **Answer:**
4101 | * Docker is a containerization platform which packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment be it development or test or production.
4102 | * Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries etc. anything that can be installed on a server.
4103 | * This guarantees that the software will always run the same, regardless of its environment.
4104 |
4105 | **Source:** _edureka.co_
4106 |
4107 | #### Q5: How to build envrionment-agnostic systems with Docker? ⭐⭐
4108 | **Answer:**
4109 | There are three main features helping to achieve that:
4110 |
4111 | * Volumes
4112 | * Environment variable injection
4113 | * Read-only file systems
4114 |
4115 | **Source:** _rafalgolarz.com_
4116 |
4117 | #### Q6: What is the difference between the `COPY` and `ADD` commands in a Dockerfile? ⭐⭐
4118 | **Answer:**
4119 | Although `ADD` and `COPY` are functionally similar, generally speaking, `COPY` is preferred.
4120 |
4121 | That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.
4122 |
4123 | **Source:** _stackoverflow.com_
4124 |
4125 | #### Q7: What is Docker image? ⭐⭐
4126 | **Answer:**
4127 | **Docker image** is the source of Docker container. In other words, Docker images are used to create containers. Images are created with the build command, and they’ll produce a container when started with run. Images are stored in a Docker registry such as ` registry.hub.docker.com` because they can become quite large, images are designed to be composed of layers of other images, allowing a minimal amount of data to be sent when transferring images over the network.
4128 |
4129 | **Source:** _edureka.co_
4130 |
4131 | #### Q8: What is Docker container? ⭐⭐
4132 | **Answer:**
4133 | **Docker containers** include the application and all of its dependencies, but share the kernel with other containers, running as isolated processes in user space on the host operating system. Docker containers are not tied to any specific infrastructure: they run on any computer, on any infrastructure, and in any cloud.
4134 |
4135 | **Source:** _edureka.co_
4136 |
4137 | #### Q9: What is Docker hub? ⭐⭐
4138 | **Answer:**
4139 | **Docker hub** is a cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images, and links to Docker cloud so you can deploy images to your hosts. It provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, and workflow automation throughout the development pipeline.
4140 |
4141 | **Source:** _edureka.co_
4142 |
4143 | #### Q10: What are the various states that a Docker container can be in at any given point in time? ⭐⭐
4144 | **Answer:**
4145 | There are four states that a Docker container can be in, at any given point in time. Those states are as given as follows:
4146 |
4147 | * Running
4148 | * Paused
4149 | * Restarting
4150 | * Exited
4151 |
4152 | **Source:** _mindmajix.com_
4153 |
4154 | #### Q11: Is there a way to identify the status of a Docker container? ⭐⭐
4155 | **Answer:**
4156 | We can identify the status of a Docker container by running the command
4157 |
4158 | ```sh
4159 | docker ps –a
4160 | ```
4161 |
4162 | which will in turn list down all the available docker containers with its corresponding statuses on the host. From there we can easily identify the container of interest to check its status correspondingly.
4163 |
4164 | **Source:** _mindmajix.com_
4165 |
4166 | #### Q12: What are the most common instructions in Dockerfile? ⭐⭐
4167 | **Answer:**
4168 |
4169 | Some of the common instructions in Dockerfile are as follows:
4170 | * **FROM**: We use FROM to set the base image for subsequent instructions. In every valid Dockerfile, FROM is the first instruction.
4171 | * **LABEL**: We use LABEL to organize our images as per project, module, licensing etc. We can also use LABEL to help in automation.
4172 | In LABEL we specify a key value pair that can be later used for programmatically handling the Dockerfile.
4173 | * **RUN**: We use RUN command to execute any instructions in a new layer on top of the current image. With each RUN command we add something on top of the image and use it in subsequent steps in Dockerfile.
4174 | * **CMD**: We use CMD command to provide default values of an executing container. In a Dockerfile, if we include multiple CMD commands, then only the last instruction is used.
4175 |
4176 | **Source:** _knowledgepowerhouse.com_
4177 |
4178 | #### Q13: What type of applications - Stateless or Stateful are more suitable for Docker Container? ⭐⭐
4179 | **Answer:**
4180 | It is preferable to create Stateless application for Docker Container. We can create a container out of our application and take out the configurable state parameters from application. Now we can run same container in Production as well as QA environments with different parameters. This helps in reusing the same Image in different scenarios. Also a stateless application is much easier to scale with Docker Containers than a stateful application.
4181 |
4182 | **Source:** _mindmajix.com_
4183 |
4184 | #### Q14: Explain basic Docker usage workflow ⭐⭐⭐
4185 | **Answer:**
4186 | 1. Everything starts with the **Dockerfile**. The Dockerfile is the source code of the Image.
4187 | 2. Once the Dockerfile is created, you build it to create the **image** of the container. The image is just the "compiled version" of the "source code" which is the Dockerfile.
4188 | 3. Once you have the image of the container, you should redistribute it using the **registry**. The registry is like a git repository -- you can push and pull images.
4189 | 4. Next, you can use the image to run **containers**. A running container is very similar, in many aspects, to a virtual machine (but without the hypervisor).
4190 |
4191 | ```sh
4192 | +------------+ docker build +--------------+ docker run -dt +-----------+ docker exec -it +------+
4193 | | Dockerfile | --------------> | Image | ---------------> | Container | -----------------> | Bash |
4194 | +------------+ +--------------+ +-----------+ +------+
4195 | ^
4196 | | docker pull
4197 | |
4198 | +--------------+
4199 | | Registry |
4200 | +--------------+
4201 | ```
4202 |
4203 |
4204 |
4205 | **Source:** _stackoverflow.com_
4206 |
4207 | #### Q15: What is the difference between Docker Image and Layer? ⭐⭐⭐
4208 | **Answer:**
4209 | - **Image**: A Docker image is built up from a series of **read-only** layers
4210 | - **Layer**: Each layer represents an instruction in the image’s Dockerfile.
4211 |
4212 | The below Dockerfile contains four commands, each of which creates a layer.
4213 | ```sh
4214 | FROM ubuntu:15.04
4215 | COPY . /app
4216 | RUN make /app
4217 | CMD python /app/app.py
4218 | ```
4219 |
4220 | Importantly, each layer is only a set of differences from the layer before it.
4221 |
4222 | **Source:** _stackoverflow.com_
4223 |
4224 | #### Q16: What is virtualisation? ⭐⭐⭐
4225 | **Answer:**
4226 | In its conceived form, **virtualisation** was considered a method of logically dividing mainframes to allow multiple applications to run simultaneously. However, the scenario drastically changed when companies and open source communities were able to provide a method of handling the privileged instructions in one way or another and allow for multiple operating systems to be run simultaneously on a single x86 based system.
4227 |
4228 | The net effect is that virtualization allows you to run two completely different OS on same hardware. Each guest OS goes through all the process of bootstrapping, loading kernel etc. You can have very tight security, for example, guest OS can't get full access to host OS or other guests and mess things up.
4229 |
4230 | The virtualization method can be categorized based on how it mimics hardware to a guest operating system and emulates guest operating environment. Primarily, there are three types of virtualization:
4231 |
4232 | * Emulation
4233 | * Paravirtualization
4234 | * Container-based virtualization
4235 |
4236 | **Source:** _stackoverflow.com_
4237 |
4238 | #### Q17: What is Hypervisor? ⭐⭐⭐
4239 | **Answer:**
4240 | The **hypervisor** handles creating the virtual environment on which the guest virtual machines operate. It supervises the guest systems and makes sure that resources are allocated to the guests as necessary. The hypervisor sits in between the physical machine and virtual machines and provides virtualization services to the virtual machines. To realize it, it intercepts the guest operating system operations on the virtual machines and emulates the operation on the host machine's operating system.
4241 |
4242 | The rapid development of virtualization technologies, primarily in cloud, has driven the use of virtualization further by allowing multiple virtual servers to be created on a single physical server with the help of hypervisors, such as Xen, VMware Player, KVM, etc., and incorporation of hardware support in commodity processors, such as Intel VT and AMD-V.
4243 |
4244 | **Source:** _stackoverflow.com_
4245 |
4246 | #### Q18: What is Docker Swarm? ⭐⭐⭐
4247 | **Answer:**
4248 | **Docker Swarm** is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host. Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.
4249 |
4250 | **Source:** _edureka.co_
4251 |
4252 | #### Q19: How will you monitor Docker in production? ⭐⭐⭐
4253 | **Answer:**
4254 | Docker provides tools like docker stats and docker events to monitor Docker in production. We can get reports on important statistics with these commands.
4255 |
4256 | * **Docker stats**: When we call docker stats with a container id, we get the CPU, memory usage etc of a container. It is similar to top command in Linux.
4257 | * **Docker events**: Docker events are a command to see the stream of activities that are going on in Docker daemon.
4258 |
4259 | Some of the common Docker events are: attach, commit, die, detach, rename, destroy etc. We can also use various options to limit or filter the events that we are interested in.
4260 |
4261 | **Source:** _knowledgepowerhouse.com_
4262 |
4263 | #### Q20: What is an orphant volume and how to remove it? ⭐⭐⭐⭐
4264 | **Answer:**
4265 | Read Full Answer on 👉 FullStack.Cafe
4266 |
4267 | #### Q21: What is Paravirtualization? ⭐⭐⭐⭐
4268 | **Answer:**
4269 | Read Full Answer on 👉 FullStack.Cafe
4270 |
4271 | #### Q22: How is Docker different from a virtual machine? ⭐⭐⭐⭐
4272 | **Answer:**
4273 | Read Full Answer on 👉 FullStack.Cafe
4274 |
4275 | #### Q23: Can you explain dockerfile ONBUILD instruction? ⭐⭐⭐⭐
4276 | **Answer:**
4277 | Read Full Answer on 👉 FullStack.Cafe
4278 |
4279 | #### Q24: Is it good practice to run stateful applications on Docker? What are the scenarios where Docker best fits in? ⭐⭐⭐⭐
4280 | **Answer:**
4281 | Read Full Answer on 👉 FullStack.Cafe
4282 |
4283 | #### Q25: Can you run Docker containers natively on Windows? ⭐⭐⭐⭐
4284 | **Answer:**
4285 | Read Full Answer on 👉 FullStack.Cafe
4286 |
4287 | #### Q26: How does Docker run containers in non-Linux systems? ⭐⭐⭐⭐⭐
4288 | **Answer:**
4289 | Read Full Answer on 👉 FullStack.Cafe
4290 |
4291 | #### Q27: How containers works at low level? ⭐⭐⭐⭐⭐
4292 | **Answer:**
4293 | Read Full Answer on 👉 FullStack.Cafe
4294 |
4295 | #### Q28: Name some limitations of containers vs VM ⭐⭐⭐⭐⭐
4296 | **Answer:**
4297 | Read Full Answer on 👉 FullStack.Cafe
4298 |
4299 | #### Q29: How to use Docker with multiple environments? ⭐⭐⭐⭐⭐
4300 | **Answer:**
4301 | Read Full Answer on 👉 FullStack.Cafe
4302 |
4303 | #### Q30: Why Docker compose does not wait for a container to be ready before moving on to start next service in dependency order? ⭐⭐⭐⭐⭐
4304 | **Answer:**
4305 | Read Full Answer on 👉 FullStack.Cafe
4306 |
4307 | ## [[⬆]](#toc) 32 jQuery Interview Questions You'll Simply Fail On
4308 | > Originally published on 👉 32 jQuery Interview Questions You'll Simply Fail On | FullStack.Cafe
4309 |
4310 | #### Q1: What is jQuery? ⭐
4311 | **Answer:**
4312 | **jQuery** is **fast, lightweight and feature-rich** client side JavaScript Library/Framework which helps in to traverse HTML DOM, make animations, add Ajax interaction, manipulate the page content, change the style and provide cool UI effect. It is one of the most popular client side library and as per a survey it runs on every second website.
4313 |
4314 | **Source:** _codeproject.com_
4315 |
4316 | #### Q2: Why do we use jQuery? ⭐⭐
4317 | **Answer:**
4318 | Due to following advantages.
4319 |
4320 | * Easy to use and learn.
4321 | * Easily expandable.
4322 | * Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
4323 | * Easy to use for DOM manipulation and traversal.
4324 | * Large pool of built in methods.
4325 | * AJAX Capabilities.
4326 | * Methods for changing or applying CSS, creating animations.
4327 | * Event detection and handling.
4328 | * Tons of plug-ins for all kind of needs.
4329 |
4330 | **Source:** _codeproject.com_
4331 |
4332 | #### Q3: How JavaScript and jQuery are different? ⭐⭐
4333 | **Answer:**
4334 | JavaScript is a language While jQuery is a library built in the JavaScript language that helps to use the JavaScript language.
4335 |
4336 | **Source:** _codeproject.com_
4337 |
4338 | #### Q4: Is jQuery a W3C standard? ⭐⭐
4339 | **Answer:**
4340 | No. jQuery is not a W3C standard.
4341 |
4342 | **Source:** _codeproject.com_
4343 |
4344 | #### Q5: What does dollar sign ($) means in jQuery? ⭐⭐
4345 | **Answer:**
4346 | Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code.
4347 |
4348 | ```js
4349 | $(document).ready(function(){
4350 | });
4351 | ```
4352 |
4353 | Over here $ sign can be replaced with "jQuery" keyword.
4354 |
4355 | ```js
4356 | jQuery(document).ready(function(){
4357 | });
4358 | ```
4359 |
4360 | **Source:** _codeproject.com_
4361 |
4362 | #### Q6: Can we have multiple document.ready() function on the same page? ⭐⭐
4363 | **Answer:**
4364 | **YES**. We can have any number of document.ready() function on the same page.
4365 |
4366 | **Source:** _codeproject.com_
4367 |
4368 | #### Q7: What is jQuery.noConflict? ⭐⭐
4369 | **Answer:**
4370 | As other client side libraries like MooTools, Prototype can be used with jQuery and they also use `$()` as their global function and to define variables. This situation creates conflict as `$()` is used by jQuery and other library as their global function. To overcome from such situations, jQuery has introduced `jQuery.noConflict()`.
4371 |
4372 | ```js
4373 | jQuery.noConflict();
4374 | // Use jQuery via jQuery(...)
4375 | jQuery(document).ready(function(){
4376 | jQuery("div").hide();
4377 | });
4378 | ```
4379 |
4380 | You can also use your own specific character in the place of `$` sign in jQuery.
4381 |
4382 | ```js
4383 | var $j = jQuery.noConflict();
4384 | // Use jQuery via jQuery(...)
4385 | $j(document).ready(function(){
4386 | $j("div").hide();
4387 | });
4388 | ```
4389 |
4390 | **Source:** _codeproject.com_
4391 |
4392 | #### Q8: What is the difference between .js and .min.js? ⭐⭐
4393 | **Answer:**
4394 | jQuery library comes in 2 different versions Development and Production/Deployment. The deployment version is also known as _minified_ version. So .min.js is basically the minified version of jQuery library file. Both the files are same as far as functionality is concerned. but .min.js is quite small in size so it loads quickly and saves bandwidth.
4395 |
4396 | **Source:** _codeproject.com_
4397 |
4398 | #### Q9: How do you select element by ID in jQuery? ⭐⭐
4399 | **Answer:**
4400 | To select element use ID selector. We need to prefix the id with "#" (hash symbol). For example, to select element with ID "txtName", then syntax would be,
4401 |
4402 | ```js
4403 | $('#txtName')
4404 | ```
4405 |
4406 | **Source:** _codeproject.com_
4407 |
4408 | #### Q10: What does $("div.parent") will select? ⭐⭐
4409 | **Answer:**
4410 | All the div element with parent class.
4411 |
4412 | **Source:** _codeproject.com_
4413 |
4414 | #### Q11: What is the use of jquery .each() function? ⭐⭐
4415 | **Answer:**
4416 | The `$.each()` function is used to iterate over a jQuery object. The `$.each()` function can be used to iterate over any collection, whether it is an object or an array.
4417 |
4418 | **Source:** _codeproject.com_
4419 |
4420 | #### Q12: Is there any difference between body onload() and document.ready() function? ⭐⭐⭐
4421 | **Answer:**
4422 | `document.ready()` function is different from body `onload()` function for several reasons:
4423 |
4424 | 1. We can have more than one `document.ready()` function in a page where we can have only one body `onload` function.
4425 | 2. `document.ready()` function is called as soon as DOM is loaded where `body.onload()` function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.
4426 |
4427 | **Source:** _codeproject.com_
4428 |
4429 | #### Q13: What are the fastest/slowest selectors in jQuery? ⭐⭐⭐
4430 | **Answer:**
4431 | ID and element selectors are the _fastest_ selectors in jQuery. Class selectors are the _slow_ compared to ID and element.
4432 |
4433 | **Source:** _codeproject.com_
4434 |
4435 | #### Q14: Which is fast document.getElementByID('txtName') or $('#txtName').? ⭐⭐⭐
4436 | **Answer:**
4437 | Native JavaScipt is always fast. jQuery method to select txtName "`$('#txtName')`" will internally makes a call to `document.getElementByID('txtName')`. As jQuery is written on top of JavaScript and it internally uses JavaScript only so JavaScript is always fast.
4438 |
4439 | **Source:** _codeproject.com_
4440 |
4441 | #### Q15: Difference between $(this) and 'this' in jQuery? ⭐⭐⭐
4442 | **Answer:**
4443 | `this` and `$(this)` refers to the same element. The only difference is the way they are used. 'this' is used in traditional sense, when 'this' is wrapped in `$()` then it becomes a jQuery object and you are able to use the power of jQuery.
4444 |
4445 | ```js
4446 | $(document).ready(function(){
4447 | $('#spnValue').mouseover(function(){
4448 | alert($(this).text());
4449 | });
4450 | });
4451 | ```
4452 |
4453 | In below example, this is an object but since it is not wrapped in `$()`, we can't use jQuery method and use the native JavaScript to get the value of span element.
4454 |
4455 | ```js
4456 | $(document).ready(function(){
4457 | $('#spnValue').mouseover(function(){
4458 | alert(this.innerText);
4459 | });
4460 | });
4461 | ```
4462 |
4463 | **Source:** _codeproject.com_
4464 |
4465 | #### Q16: What is the difference between eq() and get() methods in jQuery? ⭐⭐⭐
4466 | **Answer:**
4467 | * `eq()` returns the element as a jQuery object. This method constructs a new jQuery object from one element within that set and returns it. That means that you can use jQuery functions on it.
4468 | * `get()` return a DOM element. The method retrieve the DOM elements matched by the jQuery object. But as it is a DOM element and it is not a jQuery-wrapped object. So jQuery functions can't be used.
4469 |
4470 | **Source:** _codeproject.com_
4471 |
4472 | #### Q17: What is wrong with this code line "$('#myid\\.3').text('blah blah!!!');" ⭐⭐⭐
4473 | **Answer:**
4474 | The problem with above statement is that the selectors is having meta characters and to use any of the meta-characters ( such as !"#$%&'()\*+,./:;<=>?@\[\\\]^\`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\\\. For example, an element with id="foo.bar", can use the selector $("#foo\\\\.bar").
4475 | So the correct syntax is:
4476 |
4477 | ```js
4478 | $('#myid\\\\.3').text('blah blah!!!');
4479 | ```
4480 |
4481 | **Source:** _codeproject.com_
4482 |
4483 | #### Q18: How to create clone of any object using jQuery? ⭐⭐⭐
4484 | **Answer:**
4485 | jQuery provides `clone()` method which performs a deep copy of the set of matched elements, meaning that it copies the matched elements as well as all of their descendant elements and text nodes.
4486 |
4487 | ```js
4488 | $(document).ready(function(){
4489 | $('#btnClone').click(function(){
4490 | $('#dvText').clone().appendTo('body');
4491 | return false;
4492 | });
4493 | });
4494 | ```
4495 | The default implementation of the `clone()` method doesn't copy events unless you tell the `clone()` method to copy the events. The `clone()` method takes a parameter, if you pass true then it will copy the events as well.
4496 |
4497 | ```js
4498 | $(document).ready(function(){
4499 | $("#btnClone").bind('click', function(){
4500 | $('#dvClickme').clone(true).appendTo('body');
4501 | });
4502 | ```
4503 |
4504 | **Source:** _codeproject.com_
4505 |
4506 | #### Q19: What is difference between prop and attr? ⭐⭐⭐
4507 | **Answer:**
4508 | `attr()`: Get the value of an attribute for the first element in the set of matched elements. Whereas, `.prop()`: (Introduced in jQuery 1.6) Get the value of a property for the first element in the set of matched elements.
4509 |
4510 | Attributes carry additional information about an HTML element and come in name="value" pairs. Where Property is a representation of an attribute in the HTML DOM tree. once the browser parse your HTML code ,corresponding DOM node will be created which is an object thus having properties.
4511 |
4512 | `attr()` gives you the value of element as it was defines in the html on page load. It is always recommended to use `prop()` to get values of elements which is modified via javascript/jquery , as it gives you the original value of an element's current state. Find out more [here](http://techbrij.com/jquery-attr-vs-prop-difference).
4513 |
4514 | **Source:** _codeproject.com_
4515 |
4516 | #### Q20: What are various methods to make ajax request in jQuery? ⭐⭐⭐
4517 | **Answer:**
4518 | Using below jQuery methods, you can make ajax calls.
4519 |
4520 | * `load()` : Load a piece of html into a container DOM
4521 | * `$.getJSON()`: Load JSON with GET method.
4522 | * `$.getScript()`: Load a JavaScript file.
4523 | * `$.get()`: Use to make a GET call and play extensively with the response.
4524 | * `$.post()`: Use to make a POST call and don't want to load the response to some container DOM.
4525 | * `$.ajax()`: Use this to do something on XHR failures, or to specify ajax options (e.g. cache: true) on the fly.
4526 |
4527 | **Source:** _codeproject.com_
4528 |
4529 | #### Q21: What is the difference between $('div') and $('
') in jQuery? ⭐⭐⭐⭐
4530 | **Answer:**
4531 | Read Full Answer on 👉 FullStack.Cafe
4532 |
4533 | #### Q22: What is the difference between event.PreventDefault and "return false"? ⭐⭐⭐⭐
4534 | **Answer:**
4535 | Read Full Answer on 👉 FullStack.Cafe
4536 |
4537 | #### Q23: How do you attach a event to element which should be executed only once? ⭐⭐⭐⭐
4538 | **Answer:**
4539 | Read Full Answer on 👉 FullStack.Cafe
4540 |
4541 | #### Q24: In what situation you would use multiple version of jQuery and how would you include them? ⭐⭐⭐⭐
4542 | **Answer:**
4543 | Read Full Answer on 👉 FullStack.Cafe
4544 |
4545 | #### Q25: Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()? ⭐⭐⭐⭐
4546 | **Answer:**
4547 | Read Full Answer on 👉 FullStack.Cafe
4548 |
4549 | #### Q26: What are deferred and promise object in jQuery? ⭐⭐⭐⭐
4550 | **Answer:**
4551 | Read Full Answer on 👉 FullStack.Cafe
4552 |
4553 | #### Q27: How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request? ⭐⭐⭐⭐
4554 | **Answer:**
4555 | Read Full Answer on 👉 FullStack.Cafe
4556 |
4557 | #### Q28: What are the differences between JavaScript's window.onload and jQuery's $(document).ready() method? ⭐⭐⭐⭐
4558 | **Answer:**
4559 | Read Full Answer on 👉 FullStack.Cafe
4560 |
4561 | #### Q29: Is there any significant difference between event.preventDefault() vs. return false to stop event propagation? ⭐⭐⭐⭐
4562 | **Answer:**
4563 | Read Full Answer on 👉 FullStack.Cafe
4564 |
4565 | #### Q30: Is it possible to hold or delay document.ready execution for sometime? ⭐⭐⭐⭐⭐
4566 | **Answer:**
4567 | Read Full Answer on 👉 FullStack.Cafe
4568 |
4569 | #### Q31: Is it possible to get value of multiple CSS properties in single statement? ⭐⭐⭐⭐⭐
4570 | **Answer:**
4571 | Read Full Answer on 👉 FullStack.Cafe
4572 |
4573 | #### Q32: How can I implement my own $(document).ready functionality without using jQuery? ⭐⭐⭐⭐⭐
4574 | **Answer:**
4575 | Read Full Answer on 👉 FullStack.Cafe
4576 |
4577 | ## [[⬆]](#toc) 33 Frequently Asked Node.js Interview Questions (2020 Update)
4578 | > Originally published on 👉 33 Frequently Asked Node.js Interview Questions (2020 Update) | FullStack.Cafe
4579 |
4580 | #### Q1: What is Node.js? ⭐
4581 | **Answer:**
4582 | Node.js is a web application framework built on Google Chrome's JavaScript Engine (V8 Engine).
4583 |
4584 | Node.js comes with runtime environment on which a Javascript based script can be interpreted and executed (It is analogus to JVM to JAVA byte code). This runtime allows to execute a JavaScript code on any machine outside a browser. Because of this runtime of Node.js, JavaScript is now can be executed on server as well.
4585 |
4586 | *Node.js = Runtime Environment + JavaScript Library*
4587 |
4588 | **Source:** _tutorialspoint.com_
4589 |
4590 | #### Q2: What do you mean by Asynchronous API? ⭐⭐
4591 | **Answer:**
4592 | All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
4593 |
4594 | **Source:** _tutorialspoint.com_
4595 |
4596 | #### Q3: What are the benefits of using Node.js? ⭐⭐
4597 | **Answer:**
4598 | Following are main benefits of using Node.js
4599 |
4600 | * **Aynchronous and Event Driven** - All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
4601 | * **Very Fast** - Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.
4602 | * **Single Threaded but highly Scalable** - Node.js uses a single threaded model with event looping. Event mechanism helps server to respond in a non-bloking ways and makes server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and same program can services much larger number of requests than traditional server like Apache HTTP Server.
4603 | * **No Buffering** \- Node.js applications never buffer any data. These applications simply output the data in chunks.
4604 |
4605 | **Source:** _tutorialspoint.com_
4606 |
4607 | #### Q4: What are the key features of Node.js? ⭐⭐
4608 | **Answer:**
4609 | Let’s look at some of the key features of Node.js.
4610 |
4611 | * **Asynchronous event driven IO helps concurrent request handling –** All APIs of Node.js are asynchronous. This feature means that if a Node receives a request for some Input/Output operation, it will execute that operation in the background and continue with the processing of other requests. Thus it will not wait for the response from the previous requests.
4612 | * **Fast in Code execution –** Node.js uses the V8 JavaScript Runtime engine, the one which is used by Google Chrome. Node has a wrapper over the JavaScript engine which makes the runtime engine much faster and hence processing of requests within Node.js also become faster.
4613 | * **Single Threaded but Highly Scalable –** Node.js uses a single thread model for event looping. The response from these events may or may not reach the server immediately. However, this does not block other operations. Thus making Node.js highly scalable. Traditional servers create limited threads to handle requests while Node.js creates a single thread that provides service to much larger numbers of such requests.
4614 | * **Node.js library uses JavaScript –** This is another important aspect of Node.js from the developer’s point of view. The majority of developers are already well-versed in JavaScript. Hence, development in Node.js becomes easier for a developer who knows JavaScript.
4615 | * **There is an Active and vibrant community for the Node.js framework –** The active community always keeps the framework updated with the latest trends in the web development.
4616 | * **No Buffering –** Node.js applications never buffer any data. They simply output the data in chunks.
4617 |
4618 | **Source:** _techbeamers.com_
4619 |
4620 | #### Q5: What is libuv? ⭐⭐
4621 | **Answer:**
4622 | **libuv** is a C library that is used to abstract non-blocking I/O operations to a consistent interface across all supported platforms. It provides mechanisms to handle file system, DNS, network, child processes, pipes, signal handling, polling and streaming. It also includes a thread pool for offloading work for some things that can't be done asynchronously at the operating system level.
4623 |
4624 | **Source:** _nodejs.org_
4625 |
4626 | #### Q6: What is a blocking code? ⭐⭐⭐
4627 | **Answer:**
4628 | If application has to wait for some I/O operation in order to complete its execution any further then the code responsible for waiting is known as blocking code.
4629 |
4630 | **Source:** _tutorialspoint.com_
4631 |
4632 | #### Q7: What is difference between synchronous and asynchronous method of fs module? ⭐⭐⭐
4633 | **Answer:**
4634 |
4635 | Every method in `fs` module has synchronous as well as asynchronous form. Asynchronous methods takes a last parameter as completion function callback and first parameter of the callback function is error. It is preferred to use asynchronous method instead of synchronous method as former never block the program execution where the latter one does.
4636 |
4637 | **Source:** _tutorialspoint.com_
4638 |
4639 | #### Q8: What is Chaining in Node? ⭐⭐⭐
4640 | **Answer:**
4641 | **Chanining** is a mechanism to connect output of one stream to another stream and create a chain of multiple stream operations. It is normally used with piping operations.
4642 |
4643 | **Source:** _tutorialspoint.com_
4644 |
4645 | #### Q9: What's the event loop? ⭐⭐⭐
4646 | **Answer:**
4647 | **The event loop** is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.
4648 |
4649 |
4650 |
4651 |
4652 |
4653 | Every I/O requires a callback - once they are done they are pushed onto the event loop for execution. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback may be added to the poll queue to eventually be executed.
4654 |
4655 | **Source:** _blog.risingstack.com_
4656 |
4657 | #### Q10: When should we use Node.js? ⭐⭐⭐
4658 | **Answer:**
4659 | **Node.js** is well suited for applications that have a lot of concurrent connections and each _request only needs very few CPU cycles_, because the event loop (with all the other clients) is blocked during execution of a function. I believe Node.js is best suited for real-time applications: online games, collaboration tools, chat rooms, or anything where what one user (or robot? or sensor?) does with the application needs to be seen by other users immediately, without a page refresh.
4660 |
4661 | **Source:** _techbeamers.com_
4662 |
4663 | #### Q11: How does Node.js handle child threads? ⭐⭐⭐
4664 | **Answer:**
4665 | Node.js, in its essence, is a single thread process. It does not expose child threads and thread management methods to the developer. Technically, Node.js does spawn child threads for certain tasks such as asynchronous I/O, but these run behind the scenes and do not execute any application JavaScript code, nor block the main event loop.
4666 |
4667 | If threading support is desired in a Node.js application, there are tools available to enable it, such as the ChildProcess module.
4668 |
4669 | **Source:** _lazyquestion.com_
4670 |
4671 | #### Q12: What is the preferred method of resolving unhandled exceptions in Node.js? ⭐⭐⭐
4672 | **Answer:**
4673 | Unhandled exceptions in Node.js can be caught at the `Process` level by attaching a handler for `uncaughtException` event.
4674 |
4675 | ```js
4676 | process.on('uncaughtException', function(err) {
4677 | console.log('Caught exception: ' + err);
4678 | });
4679 | ```
4680 | However, `uncaughtException` is a very crude mechanism for exception handling and may be removed from Node.js in the future. An exception that has bubbled all the way up to the `Process` level means that your application, and Node.js may be in an undefined state, and the only sensible approach would be to restart everything.
4681 |
4682 | The preferred way is to add another layer between your application and the Node.js process which is called the [domain](http://nodejs.org/api/domain.html).
4683 |
4684 | Domains provide a way to handle multiple different I/O operations as a single group. So, by having your application, or part of it, running in a separate domain, you can safely handle exceptions at the domain level, before they reach the `Process` level.
4685 |
4686 | **Source:** _lazyquestion.com_
4687 |
4688 | #### Q13: How to use Buffer in Node.js? ⭐⭐⭐
4689 | **Answer:**
4690 | Buffer is used to process binary data, such as pictures, mp3, database files, etc. Buffer supports a variety of encoding and decoding, binary string conversion.
4691 |
4692 | **Source:** _github.com/jimuyouyou_
4693 |
4694 | #### Q14: Rewrite promise-based Node.js applications to Async/Await ⭐⭐⭐
4695 | **Details:**
4696 | Rewrite this code to Async/Await:
4697 | ```js
4698 | function asyncTask() {
4699 | return functionA()
4700 | .then((valueA) => functionB(valueA))
4701 | .then((valueB) => functionC(valueB))
4702 | .then((valueC) => functionD(valueC))
4703 | .catch((err) => logger.error(err))
4704 | }
4705 | ```
4706 |
4707 |
4708 | **Answer:**
4709 | ```js
4710 | async function asyncTask() {
4711 | try {
4712 | const valueA = await functionA()
4713 | const valueB = await functionB(valueA)
4714 | const valueC = await functionC(valueB)
4715 | return await functionD(valueC)
4716 | } catch (err) {
4717 | logger.error(err)
4718 | }
4719 | }
4720 | ```
4721 |
4722 | **Source:** _stackoverflow.com_
4723 |
4724 | #### Q15: Are you familiar with differences between Node.js nodules and ES6 nodules? ⭐⭐⭐
4725 | **Answer:**
4726 | The modules used in Node.js follow a module specification known as the **CommonJS** specification. The recent updates to the JavaScript programming language, in the form of ES6, specify changes to the language, adding things like new class syntax and a module system. This module system is different from Node.js modules. To import ES6 module, we'd use the ES6 `import` functionality.
4727 |
4728 | Now ES6 modules are incompatible with Node.js modules. This has to do with the way modules are loaded differently between the two formats. If you use a compiler like Babel, you can mix and match module formats.
4729 |
4730 | **Source:** _stackoverflow.com_
4731 |
4732 | #### Q16: Name some of the events fired by streams. ⭐⭐⭐⭐
4733 | **Answer:**
4734 | Read Full Answer on 👉 FullStack.Cafe
4735 |
4736 | #### Q17: What's a stub? Name a use case. ⭐⭐⭐⭐
4737 | **Answer:**
4738 | Read Full Answer on 👉 FullStack.Cafe
4739 |
4740 | #### Q18: Is Node.js entirely based on a single-thread? ⭐⭐⭐⭐
4741 | **Answer:**
4742 | Read Full Answer on 👉 FullStack.Cafe
4743 |
4744 | #### Q19: When to not use Node.js? ⭐⭐⭐⭐
4745 | **Answer:**
4746 | Read Full Answer on 👉 FullStack.Cafe
4747 |
4748 | #### Q20: What are the timing features of Node.js? ⭐⭐⭐⭐
4749 | **Answer:**
4750 | Read Full Answer on 👉 FullStack.Cafe
4751 |
4752 | #### Q21: How would you handle errors for async code in Node.js? ⭐⭐⭐⭐
4753 | **Answer:**
4754 | Read Full Answer on 👉 FullStack.Cafe
4755 |
4756 | #### Q22: How do you convert an existing callback API to promises? ⭐⭐⭐⭐
4757 | **Details:**
4758 | How to convert this callback code to Promise? Provide some examples.
4759 | ```js
4760 | function divisionAPI (number, divider, successCallback, errorCallback) {
4761 | if (divider == 0) {
4762 | return errorCallback( new Error("Division by zero") )
4763 | }
4764 | successCallback( number / divider )
4765 | }
4766 | ```
4767 |
4768 | **Answer:**
4769 | Read Full Answer on 👉 FullStack.Cafe
4770 |
4771 | #### Q23: Can Node.js work without V8? ⭐⭐⭐⭐
4772 | **Answer:**
4773 | Read Full Answer on 👉 FullStack.Cafe
4774 |
4775 | #### Q24: Is it possible to use "Class" in Node.js? ⭐⭐⭐⭐
4776 | **Answer:**
4777 | Read Full Answer on 👉 FullStack.Cafe
4778 |
4779 | #### Q25: Can Node.js use other engines than V8? ⭐⭐⭐⭐⭐
4780 | **Answer:**
4781 | Read Full Answer on 👉 FullStack.Cafe
4782 |
4783 | #### Q26: What is the difference between process.nextTick() and setImmediate() ? ⭐⭐⭐⭐⭐
4784 | **Answer:**
4785 | Read Full Answer on 👉 FullStack.Cafe
4786 |
4787 | #### Q27: Explain what is Reactor Pattern in Node.js? ⭐⭐⭐⭐⭐
4788 | **Answer:**
4789 | Read Full Answer on 👉 FullStack.Cafe
4790 |
4791 | #### Q28: Why should you separate Express 'app' and 'server'? ⭐⭐⭐⭐⭐
4792 | **Answer:**
4793 | Read Full Answer on 👉 FullStack.Cafe
4794 |
4795 | #### Q29: How many threads does Node actually create? ⭐⭐⭐⭐⭐
4796 | **Answer:**
4797 | Read Full Answer on 👉 FullStack.Cafe
4798 |
4799 | #### Q30: How V8 compiles JavaScript code? ⭐⭐⭐⭐⭐
4800 | **Answer:**
4801 | Read Full Answer on 👉 FullStack.Cafe
4802 |
4803 | #### Q31: What is V8 Templates? ⭐⭐⭐⭐⭐
4804 | **Answer:**
4805 | Read Full Answer on 👉 FullStack.Cafe
4806 |
4807 | #### Q32: Why Node.js devs tend to lean towards the Module Requiring vs Dependency Injection? ⭐⭐⭐⭐⭐
4808 | **Answer:**
4809 | Read Full Answer on 👉 FullStack.Cafe
4810 |
4811 | #### Q33: What will happen when that code will be executed? ⭐⭐⭐⭐⭐
4812 | **Details:**
4813 |
4814 | What will happen when that code will be executed?
4815 | ```js
4816 | var EventEmitter = require('events');
4817 |
4818 | var crazy = new EventEmitter();
4819 |
4820 | crazy.on('event1', function () {
4821 | console.log('event1 fired!');
4822 | process.nextTick(function () {
4823 | crazy.emit('event2');
4824 | });
4825 | });
4826 |
4827 | crazy.on('event2', function () {
4828 | console.log('event2 fired!');
4829 | process.nextTick(function () {
4830 | crazy.emit('event3');
4831 | });
4832 |
4833 | });
4834 |
4835 | crazy.on('event3', function () {
4836 | console.log('event3 fired!');
4837 | process.nextTick(function () {
4838 | crazy.emit('event1');
4839 | });
4840 | });
4841 |
4842 | crazy.emit('event1');
4843 | ```
4844 |
4845 | **Answer:**
4846 | Read Full Answer on 👉 FullStack.Cafe
4847 |
4848 | ## [[⬆]](#toc) 35 LINQ Interview Questions and Answers in 2019
4849 | > Originally published on 👉 35 LINQ Interview Questions and Answers in 2019 | FullStack.Cafe
4850 |
4851 | #### Q1: What is LINQ? ⭐
4852 | **Answer:**
4853 | **LINQ** stands for Language INtegrated Query. LINQ allows us to write queries over local collection objects and remote data sources like SQL, XML documents etc. We can write LINQ query on any collection class which implements the `IEnumerable` interface.
4854 |
4855 | **Source:** _stackoverflow.com_
4856 |
4857 | #### Q2: What are the types of LINQ? ⭐
4858 | **Answer:**
4859 | * LINQ to Objects
4860 | * LINQ to XML
4861 | * LINQ to Dataset
4862 | * LINQ to SQL
4863 | * LINQ to Entities
4864 |
4865 | **Source:** _career.guru99.com_
4866 |
4867 | #### Q3: Explain what is LINQ? Why is it required? ⭐
4868 | **Answer:**
4869 | **Language Integrated Query** or **LINQ** is the collection of standard query operators which provides query facilities into.NET framework language like C#, VB.NET. LINQ is required as it bridges the gap between the world of data and the world of objects.
4870 |
4871 | **Source:** _career.guru99.com_
4872 |
4873 | #### Q4: List out the three main components of LINQ? ⭐⭐
4874 | **Answer:**
4875 | Three main components of LINQ are
4876 |
4877 | * Standard Query Operators
4878 | * Language Extensions
4879 | * LINQ Providers
4880 |
4881 | **Source:** _career.guru99.com_
4882 |
4883 | #### Q5: What is Anonymous function? ⭐⭐
4884 | **Answer:**
4885 | An Anonymous function is a special function which does not have any name. We just define their parameters and define the code into the curly braces.
4886 |
4887 | Consider:
4888 | ```csharp
4889 | delegate int func(int a, int b);
4890 | static void Main(string[] args)
4891 | {
4892 | func f1 = delegate(int a, int b)
4893 | {
4894 | return a + b;
4895 | };
4896 |
4897 | Console.WriteLine(f1(1, 2));
4898 | }
4899 | ```
4900 |
4901 | **Source:** _stackoverflow.com_
4902 |
4903 | #### Q6: What are Anonymous Types? ⭐⭐
4904 | **Answer:**
4905 | Anonymous types are types that are generated by compiler at run time. When we create a anonymous type we do not specify a name. We just write properties names and their values. Compiler at runtime create these properties and assign values to them.
4906 |
4907 | ```csharp
4908 | var k = new { FirstProperty = "value1", SecondProperty = "value2" };
4909 | Console.WriteLine(k.FirstProperty);
4910 | ```
4911 |
4912 | Anonymous class is useful in LINQ queries to save our intermediate results.
4913 |
4914 | There are some restrictions on Anonymous types as well:
4915 |
4916 | * Anonymous types can not implement interfaces.
4917 | * Anonymous types can not specify any methods.
4918 | * We can not define static members.
4919 | * All defined properties must be initialized.
4920 | * We can only define public fields.
4921 |
4922 | **Source:** _stackoverflow.com_
4923 |
4924 | #### Q7: What are Extension Methods? ⭐⭐
4925 | **Answer:**
4926 | **Extension methods** are static functions of a static class. These methods can be invoked just like instance method syntax. These methods are useful when we can not want to modify the class. Consider:
4927 |
4928 | ```csharp
4929 | public static class StringMethods
4930 | {
4931 | public static bool IsStartWithLetterM(this string s)
4932 | {
4933 | return s.StartsWith("m");
4934 | }
4935 | }
4936 | class Program
4937 | {
4938 | static void Main(string[] args)
4939 | {
4940 | string value = "malslfds";
4941 | Console.WriteLine(value.IsStartWithLetterM()); //print true;
4942 |
4943 | Console.ReadLine();
4944 | }
4945 | }
4946 | ```
4947 |
4948 | **Source:** _stackoverflow.com_
4949 |
4950 | #### Q8: Explain what is “LINQ to Objects”? ⭐⭐
4951 | **Answer:**
4952 | When LINQ queries any `IEnumerable()` collection or IEnumerable directly without the use of an intermediate LINQ provider or API such as LINQ to SQL or LINQ to XML is referred as **LINQ to Objects**.
4953 |
4954 | **Source:** _career.guru99.com_
4955 |
4956 | #### Q9: Explain what is the purpose of LINQ providers in LINQ? ⭐⭐
4957 | **Answer:**
4958 | LINQ providers are set of classes that take an LINQ query which generates method that executes an equivalent query against a particular data source.
4959 |
4960 | **Source:** _career.guru99.com_
4961 |
4962 | #### Q10: Mention what is the role of DataContext classes in LINQ? ⭐⭐
4963 | **Answer:**
4964 | **DataContext** class acts as a bridge between SQL Server database and the LINQ to SQL. For accessing the database and also for changing the data in the database, it contains connections string and the functions. Essentially a DataContext class performs the following three tasks:
4965 |
4966 | * Create connection to database.
4967 | * It submits and retrieves object to database.
4968 | * Converts objects to SQL queries and vice versa.
4969 |
4970 | **Source:** _career.guru99.com_
4971 |
4972 | #### Q11: In LINQ how will you find the index of the element using where() with Lambda Expressions? ⭐⭐
4973 | **Answer:**
4974 | In order to find the index of the element use the overloaded version of `where()` with the lambda expression:
4975 |
4976 | ```csharp
4977 | where(( i, ix ) => i == ix);
4978 | ```
4979 |
4980 | **Source:** _career.guru99.com_
4981 |
4982 | #### Q12: Explain how LINQ is useful than Stored Procedures? ⭐⭐
4983 | **Answer:**
4984 | * **Debugging:** It is difficult to debug a stored procedure but as LINQ is part of.NET, visual studio debugger can be used to debug the queries
4985 | * **Deployment:** For stored procedure, additional script should be provided but with LINQ everything gets compiled into single DLL hence deployment becomes easy
4986 | * **Type Safety:** LINQ is type safe, so queries errors are type checked at compile time
4987 |
4988 | **Source:** _career.guru99.com_
4989 |
4990 | #### Q13: Explain why SELECT clause comes after FROM clause in LINQ? ⭐⭐
4991 | **Answer:**
4992 | With other programming language and C#, LINQ is used, it requires all the variables to be declared first. “FROM” clause of LINQ query defines the range or conditions to select records. So, FROM clause must appear before SELECT in LINQ.
4993 |
4994 | **Source:** _career.guru99.com_
4995 |
4996 | #### Q14: Could you compare Entity Framework vs LINQ to SQL vs ADO.NET with stored procedures? ⭐⭐⭐
4997 | **Answer:**
4998 | **Stored procedures:**
4999 |
5000 | (++)
5001 |
5002 | - Great flexibility
5003 | - Full control over SQL
5004 | - The highest performance available
5005 |
5006 | (--)
5007 |
5008 | - Requires knowledge of SQL
5009 | - Stored procedures are out of source control (harder to test)
5010 | - Substantial amount of "repeating yourself" while specifying the same table and field names. The high chance of breaking the application after renaming a DB entity and missing some references to it somewhere.
5011 | - Slow development
5012 |
5013 | **ORM (EF, L2SQL, ADO.NET):**
5014 |
5015 | (++)
5016 |
5017 | - Rapid development
5018 | - Data access code now under source control
5019 | - You're isolated from changes in DB. If that happens you only need to update your model/mappings in one place.
5020 |
5021 | (--)
5022 |
5023 | - Performance may be worse
5024 | - No or little control over SQL the ORM produces (could be inefficient or worse buggy). Might need to intervene and replace it with custom stored procedures. That will render your code messy (some LINQ in code, some SQL in code and/or in the DB out of source control).
5025 | - As any abstraction can produce "high-level" developers having no idea how it works under the hood
5026 |
5027 | **Source:** _stackoverflow.com_
5028 |
5029 | #### Q15: When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference? ⭐⭐⭐
5030 | **Answer:**
5031 | * **LINQ to SQL** only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5.
5032 |
5033 | * **LINQ to Entities** (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the .Net Framework 3.5 SP1.
5034 |
5035 | **Source:** _stackoverflow.com_
5036 |
5037 | #### Q16: Using LINQ to remove elements from a List ⭐⭐⭐
5038 | **Details:**
5039 | Given that `authorsList` is of type `List`, how can I delete the `Author` elements that are equalling to `Bob`?
5040 |
5041 | **Answer:**
5042 | Consider:
5043 | ```csharp
5044 | authorsList.RemoveAll(x => x.FirstName == "Bob");
5045 | ```
5046 |
5047 | **Source:** _stackoverflow.com_
5048 |
5049 | #### Q17: What is the difference between First() and Take(1)? ⭐⭐⭐
5050 | **Details:**
5051 | Consider:
5052 | ```csharp
5053 | var result = List.Where(x => x == "foo").First();
5054 | var result = List.Where(x => x == "foo").Take(1);
5055 | ```
5056 |
5057 | **Answer:**
5058 | The difference between `First()` and `Take()` is that `First()` returns the element itself, while `Take()` returns a sequence of elements that contains exactly one element. (If you pass 1 as the parameter).
5059 |
5060 | **Source:** _stackoverflow.com_
5061 |
5062 | #### Q18: When to use First() and when to use FirstOrDefault() with LINQ? ⭐⭐⭐
5063 | **Answer:**
5064 | * Use `First()` when you know or expect the sequence to have at least one element. In other words, when it is an exceptional occurrence that the sequence is empty.
5065 | * Use `FirstOrDefault()` when you know that you will need to check whether there was an element or not. In other words, when it is legal for the sequence to be empty. You should not rely on exception handling for the check. (It is bad practice and might hurt performance).
5066 |
5067 | `First()` will throw an exception if there's no row to be returned, while `FirstOrDefault()` will return the default value (NULL for all reference types) instead.
5068 |
5069 | **Source:** _stackoverflow.com_
5070 |
5071 | #### Q19: Explain how standard query operators useful in LINQ? ⭐⭐⭐
5072 | **Answer:**
5073 | A set of extension methods forming a query pattern is known as LINQ Standard Query Operators. As building blocks of LINQ query expressions, these operators offer a range of query capabilities like filtering, sorting, projection, aggregation, etc.
5074 |
5075 | LINQ standard query operators can be categorized into the following ones on the basis of their functionality.
5076 |
5077 | * Filtering Operators (Where, OfType)
5078 | * Join Operators (Join, GroupJoin)
5079 | * Projection Operations (Select, SelectMany)
5080 | * Sorting Operators (OrderBy, ThenBy, Reverse, ...)
5081 | * Grouping Operators (GroupBy, ToLookup)
5082 | * Conversions (Cast, ToArray, ToList, ...)
5083 | * Concatenation (Concat)
5084 | * Aggregation (Aggregate, Average, Count, Max, ...)
5085 | * Quantifier Operations (All, Any, Contains)
5086 | * Partition Operations (Skip, SkipWhile, Take, ...)
5087 | * Generation Operations (DefaultIfEmpty, Empty, Range, Repeat)
5088 | * Set Operations (Distinct, Except, ...)
5089 | * Equality (SequenceEqual)
5090 | * Element Operators (ElementAt, First, Last, ...)
5091 |
5092 | **Source:** _tutorialspoint.com_
5093 |
5094 | #### Q20: What is Expression Trees and how they used in LINQ? ⭐⭐⭐
5095 | **Answer:**
5096 | An **Expression Tree** is a data structure that contains Expressions, which is basically code. So it is a tree structure that represents a calculation you may make in code. These pieces of code can then be executed by "running" the expression tree over a set of data.
5097 |
5098 | In LINQ, expression trees are used to represent structured queries that target sources of data that implement `IQueryable`. For example, the LINQ provider implements the `IQueryable` interface for querying relational data stores. The C# compiler compiles queries that target such data sources into code that builds an expression tree at runtime. The query provider can then traverse the expression tree data structure and translate it into a query language appropriate for the data source.
5099 |
5100 | **Source:** _docs.microsoft.com_
5101 |
5102 | #### Q21: Could you explian what is the exact deference between deferred execution and Lazy evaluation in C#? ⭐⭐⭐
5103 | **Answer:**
5104 | In practice, they mean essentially the same thing. However, it's preferable to use the term deferred.
5105 |
5106 | * Lazy means "don't do the work until you absolutely have to."
5107 | * Deferred means "don't compute the result until the caller actually uses it."
5108 |
5109 | When the caller decides to use the result of an evaluation (i.e. start iterating through an `IEnumerable`), that is precisely the point at which the "work" needs to be done (such as issuing a query to the database).
5110 |
5111 | The term _deferred_ is more specific/descriptive as to what's actually going on. When I say that I am lazy, it means that I avoid doing unnecessary work; it's ambiguous as to what that really implies. However, when I say that execution/evaluation is deferred, it essentially means that I am not giving you the real result at all, but rather a ticket you can use to claim the result. I defer actually going out and getting that result until you claim it.
5112 |
5113 | **Source:** _stackoverflow.com_
5114 |
5115 | #### Q22: Explain what are LINQ compiled queries? ⭐⭐⭐
5116 | **Answer:**
5117 | There may be scenario where we need to execute a particular query many times and repeatedly. LINQ allows us to make this task very easy by enabling us to create a query and make it compiled always. Benefits of Compiled Queries:
5118 |
5119 | * Query does need to compiled each time so execution of the query is fast.
5120 | * Query is compiled once and can be used any number of times.
5121 | * Query does need to be recompiled even if the parameter of the query is being changed.
5122 |
5123 | Consider:
5124 | ```csharp
5125 | static class MyCompliedQueries {
5126 | public static Func > CompliedQueryForPerson =
5127 | CompiledQuery.Compile((DataClasses1DataContext context) = >from c in context.Persons select c);
5128 | }
5129 | ```
5130 |
5131 | **Source:** _career.guru99.com_
5132 |
5133 | #### Q23: Get the indexes of top n items where item value = true ⭐⭐⭐
5134 | **Details:**
5135 | I have a `List`. I need to get the indexes of top n items where item `value = true`.
5136 |
5137 | ```csharp
5138 | 10011001000
5139 |
5140 | TopTrueIndexes(3) = The first 3 indexes where bits are true are 0, 3, 4
5141 | TopTrueIndexes(4) = The first 4 indexes where bits are true are 0, 3, 4, 7
5142 | ```
5143 |
5144 |
5145 | **Answer:**
5146 | Assuming you have some easily-identifiable condition, you can do something like this, which will work for any `IEnumerable`:
5147 | ```csharp
5148 | var query = source.Select((value, index) => new { value, index })
5149 | .Where(x => x.value => Condition(value))
5150 | .Select(x => x.index)
5151 | .Take(n);
5152 | ```
5153 | The important bits are that you use the overload of `Select` to get index/value pairs before the Where, and then another Select to get just the indexes after the Where... and use Take to only get the first n results.
5154 |
5155 | **Source:** _stackoverflow.com_
5156 |
5157 | #### Q24: Define what is Let clause? ⭐⭐⭐
5158 | **Answer:**
5159 | In a query expression, it is sometimes useful to store the result of a sub-expression in order to use it in subsequent clauses. You can do this with the `let` keyword, which creates a new range variable and initializes it with the result of the expression you supply.
5160 |
5161 | Consider:
5162 | ```csharp
5163 | var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" };
5164 | var result =
5165 | from animalName in names
5166 | let nameLength = animalName.Length
5167 | where nameLength > 3
5168 | orderby nameLength
5169 | select animalName;
5170 | ```
5171 |
5172 | **Source:** _career.guru99.com_
5173 |
5174 | #### Q25: Explain what is the difference between Skip() and SkipWhile() extension method? ⭐⭐⭐
5175 | **Answer:**
5176 | * **Skip()** **:** It will take an integer argument and from the given `IEnumerable` it skips the top `n` numbers
5177 | * **SkipWhile ():** It will continue to skip the elements as far as the input condition is `true`. It will return all remaining elements if the condition is `false`.
5178 |
5179 | **Source:** _career.guru99.com_
5180 |
5181 | #### Q26: Explain what is lambda expressions in LINQ? ⭐⭐⭐
5182 | **Answer:**
5183 | **Lambda expression** is referred as a unique function use to form delegates or expression tree types, where right side is the output and left side is the input to the method. For writing LINQ queries particularly, Lambda expression is used.
5184 |
5185 | **Source:** _career.guru99.com_
5186 |
5187 | #### Q27: Name some advantages of LINQ over Stored Procedures ⭐⭐⭐⭐
5188 | **Answer:**
5189 | Read Full Answer on 👉 FullStack.Cafe
5190 |
5191 | #### Q28: What are the benefits of a Deferred Execution in LINQ? ⭐⭐⭐⭐
5192 | **Answer:**
5193 | Read Full Answer on 👉 FullStack.Cafe
5194 |
5195 | #### Q29: When should I use a CompiledQuery? ⭐⭐⭐⭐
5196 | **Answer:**
5197 | Read Full Answer on 👉 FullStack.Cafe
5198 |
5199 | #### Q30: What is an equivalent to the "let" keyword in chained LINQ extension method calls? ⭐⭐⭐⭐
5200 | **Answer:**
5201 | Read Full Answer on 👉 FullStack.Cafe
5202 |
5203 | #### Q31: Can you provide a concise distinction between anonymous method and lambda expressions? ⭐⭐⭐⭐⭐
5204 | **Answer:**
5205 | Read Full Answer on 👉 FullStack.Cafe
5206 |
5207 | #### Q32: Name some disadvantages of LINQ over sprocs ⭐⭐⭐⭐⭐
5208 | **Answer:**
5209 | Read Full Answer on 👉 FullStack.Cafe
5210 |
5211 | #### Q33: What is the difference between Select and SelectMany? ⭐⭐⭐⭐⭐
5212 | **Answer:**
5213 | Read Full Answer on 👉 FullStack.Cafe
5214 |
5215 | #### Q34: What is the difference between returning IQueryable vs. IEnumerable? ⭐⭐⭐⭐⭐
5216 | **Details:**
5217 | What is the difference between returning `IQueryable` vs. `IEnumerable`?
5218 |
5219 | ```csharp
5220 | IQueryable < Customer > custs = from c in db.Customers
5221 | where c.City == ""
5222 | select c;
5223 |
5224 | IEnumerable < Customer > custs = from c in db.Customers
5225 | where c.City == ""
5226 | select c;
5227 | ```
5228 |
5229 | Will both be deferred execution and when should one be preferred over the other?
5230 |
5231 | **Answer:**
5232 | Read Full Answer on 👉 FullStack.Cafe
5233 |
5234 | #### Q35: Why use .AsEnumerable() rather than casting to IEnumerable? ⭐⭐⭐⭐⭐
5235 | **Answer:**
5236 | Read Full Answer on 👉 FullStack.Cafe
5237 |
5238 | ## [[⬆]](#toc) 35 Microservices Interview Questions You Most Likely Can't Answer
5239 | > Originally published on 👉 35 Microservices Interview Questions You Most Likely Can't Answer | FullStack.Cafe
5240 |
5241 | #### Q1: What is meant by Continuous Integration? ⭐
5242 | **Answer:**
5243 | *Continuous Integration (CI)* is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
5244 |
5245 | **Source:** _edureka.co_
5246 |
5247 | #### Q2: What does Containerization mean? ⭐⭐
5248 | **Answer:**
5249 | *Containerisation* is a type of *virtualization* strategy that emerged as an alternative to traditional hypervisor-based virtualization.
5250 |
5251 | In containerization, the operating system is shared by the different containers rather than cloned for each virtual machine. For example Docker provides a container virtualization platform that serves as a good alternative to hypervisor-based arrangements.
5252 |
5253 | **Source:** _linoxide.com_
5254 |
5255 | #### Q3: Explain Blue-Green Deployment Technique ⭐⭐⭐
5256 | **Answer:**
5257 | **Blue-green deployment** is a technique that reduces downtime and risk by running two identical production environments called Blue and Green. At any time, only one of the environments is live, with the live environment serving all production traffic. For this example, Blue is currently live and Green is idle.
5258 |
5259 | As you prepare a new version of your software, deployment and the final stage of testing takes place in the environment that is not live: in this example, Green. Once you have deployed and fully tested the software in Green, you switch the router so all incoming requests now go to Green instead of Blue. Green is now live, and Blue is idle.
5260 |
5261 | This technique can eliminate downtime due to application deployment. In addition, blue-green deployment reduces risk: if something unexpected happens with your new version on Green, you can immediately roll back to the last version by switching back to Blue.
5262 |
5263 | **Source:** _cloudfoundry.org_
5264 |
5265 | #### Q4: What's the difference between a blue/green deployment and a rolling deployment? ⭐⭐⭐
5266 | **Answer:**
5267 | * In **Blue Green Deployment**, you have TWO complete environments.
5268 | One is Blue environment which is running and the Green environment to which you want to upgrade. Once you swap the environment from blue to green, the traffic is directed to your new green environment. You can delete or save your old blue environment for backup until the green environment is stable.
5269 |
5270 | * In **Rolling Deployment**, you have only ONE complete environment. The code is deployed in the subset of instances of the same environment and moves to another subset after completion.
5271 |
5272 | **Source:** _stackoverflow.com_
5273 |
5274 | #### Q5: What are the differences between continuous integration, continuous delivery, and continuous deployment? ⭐⭐⭐
5275 | **Answer:**
5276 | * Developers practicing **continuous integration** merge their changes back to the main branch as often as possible. By doing so, you avoid the integration hell that usually happens when people wait for release day to merge their changes into the release branch.
5277 | * **Continuous delivery** is an extension of continuous integration to make sure that you can release new changes to your customers quickly in a sustainable way. This means that on top of having automated your testing, you also have automated your release process and you can deploy your application at any point of time by clicking on a button.
5278 | * **Continuous deployment** goes one step further than continuous delivery. With this practice, every change that passes all stages of your production pipeline is released to your customers. There's no human intervention, and only a failed test will prevent a new change to be deployed to production.
5279 |
5280 | **Source:** _atlassian.com_
5281 |
5282 | #### Q6: What do you know about serverless model? ⭐⭐⭐
5283 | **Answer:**
5284 | **Serverless** refers to a model where the existence of servers is hidden from developers. It means you no longer have to deal with capacity, deployments, scaling and fault tolerance and OS. It will essentially reducing maintenance efforts and allow developers to quickly focus on developing codes.
5285 |
5286 | Examples are:
5287 | * Amazon AWS Lambda
5288 | * Azure Functions
5289 |
5290 | **Source:** _linoxide.com_
5291 |
5292 | #### Q7: How is container different from a virtual machine? ⭐⭐⭐⭐
5293 | **Answer:**
5294 | Read Full Answer on 👉 FullStack.Cafe
5295 |
5296 | #### Q8: What is Canary Releasing? ⭐⭐⭐⭐⭐
5297 | **Answer:**
5298 | Read Full Answer on 👉 FullStack.Cafe
5299 |
5300 | #### Q9: What is Docker? ⭐
5301 | **Answer:**
5302 | * Docker is a containerization platform which packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment be it development or test or production.
5303 | * Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries etc. anything that can be installed on a server.
5304 | * This guarantees that the software will always run the same, regardless of its environment.
5305 |
5306 | **Source:** _edureka.co_
5307 |
5308 | #### Q10: How virtualization works at low level? ⭐⭐⭐⭐
5309 | **Answer:**
5310 | Read Full Answer on 👉 FullStack.Cafe
5311 |
5312 | #### Q11: What is Paravirtualization? ⭐⭐⭐⭐
5313 | **Answer:**
5314 | Read Full Answer on 👉 FullStack.Cafe
5315 |
5316 | #### Q12: Define Microservice Architecture ⭐⭐
5317 | **Answer:**
5318 | **Microservices**, aka **_Microservice Architecture_**, is an architectural style that structures an application as a collection of small autonomous services, modeled around a **business domain.**
5319 |
5320 | **Source:** _lambdatest.com_
5321 |
5322 | #### Q13: What are the features of Microservices? ⭐⭐⭐
5323 | **Answer:**
5324 | * **Decoupling** – Services within a system are largely decoupled. So the application as a whole can be easily built, altered, and scaled
5325 | * **Componentization** – Microservices are treated as independent components that can be easily replaced and upgraded
5326 | * **Business Capabilities** – Microservices are very simple and focus on a single capability
5327 | * **Autonomy** – Developers and teams can work independently of each other, thus increasing speed
5328 | * **Continous** **Delivery** – Allows frequent releases of software, through systematic automation of software creation, testing, and approval
5329 | * **Responsibility** – Microservices do not focus on applications as projects. Instead, they treat applications as products for which they are responsible
5330 | * **Decentralized Governance** – The focus is on using the right tool for the right job. That means there is no standardized pattern or any technology pattern. Developers have the freedom to choose the best useful tools to solve their problems
5331 | * **Agility** – Microservices support agile development. Any new feature can be quickly developed and discarded again
5332 |
5333 | **Source:** _lambdatest.com_
5334 |
5335 | #### Q14: How does Microservice Architecture work? ⭐⭐⭐
5336 | **Answer:**
5337 | * **Clients** – Different users from various devices send requests.
5338 | * **Identity Providers** – Authenticates user or clients identities and issues security tokens.
5339 | * **API Gateway** – Handles client requests.
5340 | * **Static Content** – Houses all the content of the system.
5341 | * **Management** – Balances services on nodes and identifies failures.
5342 | * **Service Discovery** – A guide to find the route of communication between microservices.
5343 | * **Content Delivery Networks** – Distributed network of proxy servers and their data centers.
5344 | * **Remote Service** – Enables the remote access information that resides on a network of IT devices.
5345 |
5346 |
5347 |
5348 |
5349 |
5350 |
5351 |
5352 | **Source:** _edureka.co_
5353 |
5354 | #### Q15: What is the difference between Monolithic, SOA and Microservices Architecture? ⭐⭐⭐
5355 | **Answer:**
5356 | * **Monolithic Architecture** is similar to a big container wherein all the software components of an application are assembled together and tightly packaged.
5357 | * A **Service-Oriented Architecture** is a collection of services which communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity.
5358 | * **Microservice Architecture** is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.
5359 |
5360 | **Source:** _edureka.co_
5361 |
5362 | #### Q16: What are main differences between Microservices and Monolithic Architecture? ⭐⭐⭐
5363 | **Answer:**
5364 | **Microservices**
5365 | * Service Startup is fast
5366 | * Microservices are loosely coupled architecture.
5367 | * Changes done in a single data model does not affect other Microservices.
5368 | * Microservices focuses on products, not projects
5369 |
5370 | **Monolithic Architecture**
5371 | * Service startup takes time
5372 | * Monolithic architecture is mostly tightly coupled.
5373 | * Any changes in the data model affect the entire database
5374 | * Monolithic put emphasize over the whole project
5375 |
5376 | **Source:** _edureka.co_
5377 |
5378 | #### Q17: What are the standard patterns of orchestrating microservices? ⭐⭐⭐
5379 | **Answer:**
5380 | As we start to model more and more complex logic, we have to deal with the problem of managing business processes that stretch across the boundary of individual services.
5381 |
5382 | * With **orchestration**, we rely on a central brain to guide and drive the process, much like the conductor in an orchestra. The orchestration style corresponds more to the SOA idea of orchestration/task services. For example we could wrap the business flow in its own service. Where the proxy orchestrates the interaction between the microservices like shown in the below picture.
5383 |
5384 | * With **choreography**, we inform each part of the system of its job, and let it work out the details, like dancers all find‐ ing their way and reacting to others around them in a ballet. The choreography style corresponds to the dumb pipes and smart endpoints mentioned by Martin Fowler's. That approach is also called the **domain approach** and is using domain events, where each service publish events regarding what have happened and other services can subscribe to those events.
5385 |
5386 |
5387 | **Source:** _stackoverflow.com_
5388 |
5389 | #### Q18: What are smart endpoints and dumb pipes? ⭐⭐⭐
5390 | **Answer:**
5391 | * **Smart endpoints** just meaning actual business rules and any other validations happens behind those endpoints which are not visible to anyone to the consumers of those endpoints think of it as a place where actual Magic happens.
5392 |
5393 | * **Dumb pipelines** means any communication means where no further actions e.g validations are taken place, it simply carries the data across that particular channel and it may also be replaceable if need be. The infrastructure chosen is typically dumb (dumb as in acts as a message router only). It just means that routing is the only function the pipes should be doing.
5394 |
5395 | **Source:** _stackoverflow.com_
5396 |
5397 | #### Q19: Whether do you find GraphQL the right fit for designing microservice architecture? ⭐⭐⭐
5398 | **Answer:**
5399 | _GraphQL and microservices are a perfect fit_, because GraphQL hides the fact that you have a microservice architecture from the clients. From a backend perspective, you want to split everything into microservices, but from a frontend perspective, you would like all your data to come from a single API. Using GraphQL is the best way I know of that lets you do both. It lets you split up your backend into microservices, while still providing a single API to all your application, and allowing joins across data from different services.
5400 |
5401 |
5402 |
5403 |
5404 |
5405 |
5406 |
5407 | **Source:** _stackoverflow.com_
5408 |
5409 | #### Q20: What is Idempotence? ⭐⭐⭐⭐
5410 | **Answer:**
5411 | Read Full Answer on 👉 FullStack.Cafe
5412 |
5413 | #### Q21: What are the pros and cons of Microservice Architecture? ⭐⭐⭐⭐
5414 | **Answer:**
5415 | Read Full Answer on 👉 FullStack.Cafe
5416 |
5417 | #### Q22: What do you understand by Contract Testing? ⭐⭐⭐⭐
5418 | **Answer:**
5419 | Read Full Answer on 👉 FullStack.Cafe
5420 |
5421 | #### Q23: What is the role of an architect in Microservices architecture? ⭐⭐⭐⭐
5422 | **Answer:**
5423 | Read Full Answer on 👉 FullStack.Cafe
5424 |
5425 | #### Q24: Explain what is the API Gateway pattern ⭐⭐⭐⭐
5426 | **Answer:**
5427 | Read Full Answer on 👉 FullStack.Cafe
5428 |
5429 | #### Q25: Mention some benefits and drawbacks of an API Gateway ⭐⭐⭐⭐
5430 | **Answer:**
5431 | Read Full Answer on 👉 FullStack.Cafe
5432 |
5433 | #### Q26: What is Materialized View pattern and when will you use it? ⭐⭐⭐⭐
5434 | **Answer:**
5435 | Read Full Answer on 👉 FullStack.Cafe
5436 |
5437 | #### Q27: What Did The Law Stated By Melvin Conway Implied? ⭐⭐⭐⭐⭐
5438 | **Answer:**
5439 | Read Full Answer on 👉 FullStack.Cafe
5440 |
5441 | #### Q28: Name the main differences between SOA and Microservices? ⭐⭐⭐⭐⭐
5442 | **Answer:**
5443 | Read Full Answer on 👉 FullStack.Cafe
5444 |
5445 | #### Q29: What is the difference between cohesion and coupling? ⭐⭐⭐⭐⭐
5446 | **Answer:**
5447 | Read Full Answer on 👉 FullStack.Cafe
5448 |
5449 | #### Q30: What is a Consumer-Driven Contract (CDC)? ⭐⭐⭐⭐⭐
5450 | **Answer:**
5451 | Read Full Answer on 👉 FullStack.Cafe
5452 |
5453 | #### Q31: What are Reactive Extensions in Microservices? ⭐⭐⭐⭐⭐
5454 | **Answer:**
5455 | Read Full Answer on 👉 FullStack.Cafe
5456 |
5457 | #### Q32: What is the most accepted transaction strategy for microservices ⭐⭐⭐⭐⭐
5458 | **Answer:**
5459 | Read Full Answer on 👉 FullStack.Cafe
5460 |
5461 | #### Q33: Why would one use sagas over 2PC and vice versa? ⭐⭐⭐⭐⭐
5462 | **Answer:**
5463 | Read Full Answer on 👉 FullStack.Cafe
5464 |
5465 | #### Q34: Provide an example of "smart pipes" and "dumb endpoint" ⭐⭐⭐⭐⭐
5466 | **Answer:**
5467 | Read Full Answer on 👉 FullStack.Cafe
5468 |
5469 | #### Q35: How would you implement SSO for Microservice Architecture? ⭐⭐⭐⭐⭐
5470 | **Answer:**
5471 | Read Full Answer on 👉 FullStack.Cafe
5472 |
5473 | ## [[⬆]](#toc) 35 Top Angular 7 Interview Questions To Crack in 2019
5474 | > Originally published on 👉 35 Top Angular 7 Interview Questions To Crack in 2019 | FullStack.Cafe
5475 |
5476 | #### Q1: What are pipes? Give me an example. ⭐
5477 | **Answer:**
5478 | A **pipe** takes in data as input and transforms it to a desired output. You can chain pipes together in potentially useful combinations. You can write your own custom pipes. Angular comes with a stock of pipes such as `DatePipe`, `UpperCasePipe`, `LowerCasePipe`, `CurrencyPipe`, and `PercentPipe`.
5479 |
5480 | Consider:
5481 | ```html
5482 | The hero's birthday is {{ birthday | date }}
5483 | ```
5484 | In this page, you'll use pipes to transform a component's birthday property into a human-friendly date.
5485 |
5486 | **Source:** _angular.io_
5487 |
5488 | #### Q2: What is the minimum definition of a component? ⭐⭐
5489 | **Answer:**
5490 | The absolute minimal configuration for a `@Component` in Angular is a template. Both template properties are set to optional because you have to define either `template` or `templateUrl`.
5491 |
5492 | When you don't define them, you will get an exception like this:
5493 | ```sh
5494 | No template specified for component 'ComponentName'
5495 | ```
5496 | A selector property is not required, as you can also use your components in a route.
5497 |
5498 | **Source:** _stackoverflow.com_
5499 |
5500 | #### Q3: What's the difference between an Angular component and module? ⭐⭐
5501 | **Answer:**
5502 | *Components* control views (html). They also communicate with other components and services to bring functionality to your app.
5503 |
5504 | *Modules* consist of one or more components. They do not control any html. Your modules declare which components can be used by components belonging to other modules, which classes will be injected by the dependency injector and which component gets bootstrapped. Modules allow you to manage your components to bring modularity to your app.
5505 |
5506 | **Source:** _stackoverflow.com_
5507 |
5508 | #### Q4: How can I select an element in a component template? ⭐⭐
5509 | **Answer:**
5510 | You can get a handle to the DOM element via ElementRef by injecting it into your component's constructor:
5511 |
5512 | ```js
5513 | constructor(myElement: ElementRef) { ... }
5514 | ```
5515 |
5516 | **Source:** _medium.com_
5517 |
5518 | #### Q5: What is an observer? ⭐⭐
5519 | **Answer:**
5520 | Observer is an interface for a consumer of push-based notifications delivered by an Observable. It has below structure,
5521 | ```javascript
5522 | interface Observer {
5523 | closed?: boolean;
5524 | next: (value: T) => void;
5525 | error: (err: any) => void;
5526 | complete: () => void;
5527 | }
5528 | ```
5529 | A handler that implements the Observer interface for receiving observable notifications will be passed as a parameter for observable as below,
5530 | ```javascript
5531 | myObservable.subscribe(myObserver);
5532 | ```
5533 | **Note:** If you don't supply a handler for a notification type, the observer ignores notifications of that type.
5534 |
5535 | **Source:** _github.com/sudheerj_
5536 |
5537 | #### Q6: What is an observable? ⭐⭐
5538 | **Answer:**
5539 | An Observable is a unique Object similar to a Promise that can help manage async code. Observables are not part of the JavaScript language so we need to rely on a popular Observable library called RxJS.
5540 | The observables are created using new keyword. Let see the simple example of observable,
5541 | ```javascript
5542 | import { Observable } from 'rxjs';
5543 |
5544 | const observable = new Observable(observer => {
5545 | setTimeout(() => {
5546 | observer.next('Hello from a Observable!');
5547 | }, 2000);
5548 | });`
5549 | ```
5550 |
5551 | **Source:** _github.com/sudheerj_
5552 |
5553 | #### Q7: What is TestBed? ⭐⭐⭐
5554 | **Answer:**
5555 | The **Angular Test Bed (ATB)** is a higher level *Angular Only* testing framework that allows us to easily test behaviours that depend on the Angular Framework.
5556 |
5557 | We still write our tests in Jasmine and run using Karma but we now have a slightly easier way to create components, handle injection, test asynchronous behaviour and interact with our application.
5558 |
5559 | The TestBed creates a dynamically-constructed Angular test module that emulates an Angular `@NgModule`.
5560 |
5561 | **Source:** _angular.io_
5562 |
5563 | #### Q8: What is Redux and how does it relate to an Angular app? ⭐⭐⭐
5564 | **Answer:**
5565 | **Redux** is a way to manage application state and improve maintainability of asynchronicity in your application by providing a single source of truth for the application state, and a unidirectional flow of data change in the application. `ngrx/store` is one implementation of Redux principles.
5566 |
5567 | **Source:** _github.com/WebPredict_
5568 |
5569 | #### Q9: What are the Core Dependencies of Angular 7? ⭐⭐⭐
5570 | **Answer:**
5571 | There are two types of core dependencies, RxJS and TypeScript.
5572 |
5573 | * **RxJS 6.3** - RxJS version 6.3 is used by Angular 7. It has no changes in the version from Angular 6
5574 |
5575 | * **TypeScript 3.1** - TypeScript version 3.1 is used by Angular 7. It is the upgrade from the version 2.9 of Angular 6.
5576 |
5577 | **Source:** _onlineinterviewquestions.com_
5578 |
5579 | #### Q10: Why Incremental DOM Has Low Memory Footprint? ⭐⭐⭐
5580 | **Answer:**
5581 | Virtual DOM creates a whole tree from scratch every time you rerender.
5582 |
5583 | Incremental DOM, on the other hand, doesn’t need any memory to rerender the view if it doesn’t change the DOM. We only have to allocate the memory when the DOM nodes are added or removed. And the size of the allocation is proportional to the size of the DOM change.
5584 |
5585 | **Source:** _blog.nrwl.io_
5586 |
5587 | #### Q11: What are the ways to control AOT compilation? ⭐⭐⭐
5588 | **Answer:**
5589 | You can control your app compilation in two ways
5590 | 1. By providing template compiler options in the `tsconfig.json` file
5591 | 2. By configuring Angular metadata with decorators
5592 |
5593 | **Source:** _github.com/sudheerj_
5594 |
5595 | #### Q12: What is activated route? ⭐⭐⭐
5596 | **Answer:**
5597 | **ActivatedRoute** contains the information about a route associated with a component loaded in an outlet. It can also be used to traverse the router state tree. The ActivatedRoute will be injected as a router service to access the information. In the below example, you can access route path and parameters,
5598 |
5599 | ```js
5600 | @Component({
5601 | ...
5602 | })
5603 | class MyComponent {
5604 | constructor(route: ActivatedRoute) {
5605 | const id: Observable < string > = route.params.pipe(map(p => p.id));
5606 | const url: Observable < string > = route.url.pipe(map(segments => segments.join('')));
5607 | // route.data includes both `data` and `resolve`
5608 | const user = route.data.pipe(map(d => d.user));
5609 | }
5610 | }
5611 | ```
5612 |
5613 |
5614 | **Source:** _github.com/sudheerj_
5615 |
5616 | #### Q13: What is router outlet? ⭐⭐⭐
5617 | **Answer:**
5618 | The **RouterOutlet** is a directive from the router library and it acts as a placeholder that marks the spot in the template where the router should display the components for that outlet. Router outlet is used as a component,
5619 | ```html
5620 |
5621 |
5622 | ```
5623 |
5624 | **Source:** _github.com/sudheerj_
5625 |
5626 | #### Q14: What are the utility functions provided by RxJS? ⭐⭐⭐
5627 | **Answer:**
5628 | The RxJS library also provides below utility functions for creating and working with observables.
5629 | 1. Converting existing code for async operations into observables
5630 | 2. Iterating through the values in a stream
5631 | 3. Mapping values to different types
5632 | 4. Filtering streams
5633 | 5. Composing multiple streams
5634 |
5635 | **Source:** _github.com/sudheerj_
5636 |
5637 | #### Q15: What is multicasting? ⭐⭐⭐
5638 | **Answer:**
5639 | **Multi-casting** is the practice of broadcasting to a list of multiple subscribers in a single execution. Let's demonstrate the multi-casting feature,
5640 | ```javascript
5641 | var source = Rx.Observable.from([1, 2, 3]);
5642 | var subject = new Rx.Subject();
5643 | var multicasted = source.multicast(subject);
5644 |
5645 | // These are, under the hood, `subject.subscribe({...})`:
5646 | multicasted.subscribe({
5647 | next: (v) => console.log('observerA: ' + v)
5648 | });
5649 | multicasted.subscribe({
5650 | next: (v) => console.log('observerB: ' + v)
5651 | });
5652 |
5653 | // This is, under the hood, `s
5654 | ```
5655 |
5656 | **Source:** _github.com/sudheerj_
5657 |
5658 | #### Q16: What is subscribing? ⭐⭐⭐
5659 | **Answer:**
5660 | An Observable instance begins publishing values only when someone subscribes to it. So you need to subscribe by calling the **subscribe()** method of the instance, passing an observer object to receive the notifications.
5661 |
5662 | Let's take an example of creating and subscribing to a simple observable, with an observer that logs the received message to the console.
5663 | ```javascript
5664 | Creates an observable sequence of 5 integers, starting from 1
5665 | const source = range(1, 5);
5666 |
5667 | // Create observer object
5668 | const myObserver = {
5669 | next: x => console.log('Observer got a next value: ' + x),
5670 | error: err => console.error('Observer got an error: ' + err),
5671 | complete: () => console.log('Observer got a complete notification'),
5672 | };
5673 |
5674 | // Execute with the observer object and Prints out each item
5675 | myObservable.subscribe(myObserver);
5676 | // => Observer got a next value: 1
5677 | // => Observer got a next value: 2
5678 | // => Observer got a next value: 3
5679 | // => Observer got a next value: 4
5680 | // => Observer got a next value: 5
5681 | // => Observer got a complete notification
5682 | ```
5683 |
5684 | **Source:** _github.com/sudheerj_
5685 |
5686 | #### Q17: How to set headers for every request in Angular? ⭐⭐⭐⭐
5687 | **Answer:**
5688 | Read Full Answer on 👉 FullStack.Cafe
5689 |
5690 | #### Q18: Why would you use renderer methods instead of using native element methods? ⭐⭐⭐⭐
5691 | **Answer:**
5692 | Read Full Answer on 👉 FullStack.Cafe
5693 |
5694 | #### Q19: What is Zone in Angular? ⭐⭐⭐⭐
5695 | **Answer:**
5696 | Read Full Answer on 👉 FullStack.Cafe
5697 |
5698 | #### Q20: What does a just-in-time (JIT) compiler do (in general)? ⭐⭐⭐⭐
5699 | **Answer:**
5700 | Read Full Answer on 👉 FullStack.Cafe
5701 |
5702 | #### Q21: What is ngUpgrage? ⭐⭐⭐⭐
5703 | **Answer:**
5704 | Read Full Answer on 👉 FullStack.Cafe
5705 |
5706 | #### Q22: Why would you use lazy loading modules in Angular app? ⭐⭐⭐⭐
5707 | **Answer:**
5708 | Read Full Answer on 👉 FullStack.Cafe
5709 |
5710 | #### Q23: What is Ivy Renderer? Is it supported by Angular 7? ⭐⭐⭐⭐
5711 | **Answer:**
5712 | Read Full Answer on 👉 FullStack.Cafe
5713 |
5714 | #### Q24: What is incremental DOM? How is it different from virtual DOM? ⭐⭐⭐⭐
5715 | **Answer:**
5716 | Read Full Answer on 👉 FullStack.Cafe
5717 |
5718 | #### Q25: What are the advantages with AOT? ⭐⭐⭐⭐
5719 | **Answer:**
5720 | Read Full Answer on 👉 FullStack.Cafe
5721 |
5722 | #### Q26: Do I need to bootstrap custom elements? ⭐⭐⭐⭐
5723 | **Answer:**
5724 | Read Full Answer on 👉 FullStack.Cafe
5725 |
5726 | #### Q27: What is the difference between pure and impure pipe? ⭐⭐⭐⭐
5727 | **Answer:**
5728 | Read Full Answer on 👉 FullStack.Cafe
5729 |
5730 | #### Q28: What is the difference between BehaviorSubject vs Observable? ⭐⭐⭐⭐⭐
5731 | **Answer:**
5732 | Read Full Answer on 👉 FullStack.Cafe
5733 |
5734 | #### Q29: What is the Angular equivalent to an AngularJS "$watch"? ⭐⭐⭐⭐⭐
5735 | **Answer:**
5736 | Read Full Answer on 👉 FullStack.Cafe
5737 |
5738 | #### Q30: Name some differences between SystemJS vs WebPack? ⭐⭐⭐⭐⭐
5739 | **Answer:**
5740 | Read Full Answer on 👉 FullStack.Cafe
5741 |
5742 | #### Q31: Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation. Explain the difference. ⭐⭐⭐⭐⭐
5743 | **Answer:**
5744 | Read Full Answer on 👉 FullStack.Cafe
5745 |
5746 | #### Q32: Why angular uses url segment? ⭐⭐⭐⭐⭐
5747 | **Answer:**
5748 | Read Full Answer on 👉 FullStack.Cafe
5749 |
5750 | #### Q33: Why did the Google team go with incremental DOM instead of virtual DOM? ⭐⭐⭐⭐⭐
5751 | **Answer:**
5752 | Read Full Answer on 👉 FullStack.Cafe
5753 |
5754 | #### Q34: Why Incremental DOM is Tree Shakable? ⭐⭐⭐⭐⭐
5755 | **Answer:**
5756 | Read Full Answer on 👉 FullStack.Cafe
5757 |
5758 | #### Q35: What's new in Angular 7? ⭐⭐⭐⭐⭐
5759 | **Answer:**
5760 | Read Full Answer on 👉 FullStack.Cafe
5761 |
5762 | ## [[⬆]](#toc) 37 ASP.NET Interview Questions You Must Know
5763 | > Originally published on 👉 37 ASP.NET Interview Questions You Must Know | FullStack.Cafe
5764 |
5765 | #### Q1: What is ViewData? ⭐
5766 | **Answer:**
5767 | Viewdata contains the key, value pairs as dictionary and this is derived from class — “ViewDataDictionary“. In action method we are setting the value for viewdata and in view the value will be fetched by typecasting.
5768 |
5769 | **Source:** _medium.com_
5770 |
5771 | #### Q2: What is ASP.Net? ⭐
5772 | **Answer:**
5773 | It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc.
5774 |
5775 |
5776 | **Source:** _guru99.com_
5777 |
5778 | #### Q3: What is ASP.NET Core? ⭐⭐
5779 | **Answer:**
5780 | ASP.NET Core is a brand new cross-platform web framework built with .NET Core framework. It is not an update to existing ASP.NET framework. It is a complete rewrite of the ASP.NET framework. It works with both .NET Core and .NET Framework.
5781 |
5782 | Main characterestics of ASP.NET Core:
5783 |
5784 | * DI Container which is quite simple and built-in. You can extend it with other popular DI containers
5785 | * Built-in and extensible structured logging. You can redirect output to as many sources as you want (file, Azure, AWS, console)
5786 | * Extensible strongly typed configuration, which can also be used to reload at run-time
5787 | * Kestrel – new, cross-platform and super fast web server which can stand alone without IIS, Nginx or Apache
5788 | * New, fully async pipeline. It is easily configured via middleware
5789 | * ASP.NET All meta package which improves development speed, and enables you to reference all Microsoft packages for ASP.NET Core and it will deploy only those that are being used by your code
5790 | * There is no _web.config_. We now use _appsettings.json_ file in combination with other sources of configuration (command line args, environment variables, etc.)
5791 | * There is no _Global._asax – We have _Startup.cs_ which is used to set up Middleware and services for DI Container.
5792 |
5793 | **Source:** _talkingdotnet.com_
5794 |
5795 | #### Q4: Can ASP.NET Core work with the .NET framework? ⭐⭐
5796 | **Answer:**
5797 | Yes. This might surprise many, but ASP.NET Core works with .NET framework and this is officially supported by Microsoft.
5798 |
5799 | ASP.NET Core works with:
5800 |
5801 | * .NET Core framework
5802 | * .NET framework
5803 |
5804 | **Source:** _talkingdotnet.com_
5805 |
5806 | #### Q5: Explain startup process in ASP.NET Core? ⭐⭐
5807 | **Answer:**
5808 | Everything starts from Program.cs
5809 | ```csharp
5810 | public static void Main(string[] args)
5811 | {
5812 | BuildWebHost(args).Run();
5813 | }
5814 |
5815 | public static IWebHost BuildWebHost(string[] args) =>
5816 | WebHost.CreateDefaultBuilder(args)
5817 | .UseStartup()
5818 | .Build();
5819 | ```
5820 |
5821 | CreateDefaultBuilder extension method will create a default configuration which will look first into `appsettings.json` files then will look for Environment variables and at the end, it will use command line arguments.
5822 |
5823 | This part will also set up default logger sources (debug and console) and load the settings for logging from appsettings.json.
5824 |
5825 | After the `CreateDefaultBuilder` finishes, then `Startup` class is executed. First, the constructor code is executed. After that, services are added to DI container via `AddServices` method that lives in Startup class. After that, an order of middleware that will handle every incoming request is set up.
5826 |
5827 | **Source:** _codingblast.com_
5828 |
5829 | #### Q6: What is the difference between ASP.NET and ASP.NET MVC? ⭐⭐
5830 | **Answer:**
5831 | ASP.NET, at its most basic level, provides a means for you to provide general HTML markup combined with server side "controls" within the event-driven programming model that can be leveraged with VB, C#, and so on. You define the page(s) of a site, drop in the controls, and provide the programmatic plumbing to make it all work.
5832 |
5833 | ASP.NET MVC is an application framework based on the Model-View-Controller architectural pattern. This is what might be considered a "canned" framework for a specific way of implementing a web site, with a page acting as the "controller" and dispatching requests to the appropriate pages in the application. The idea is to "partition" the various elements of the application, eg business rules, presentation rules, and so on.
5834 |
5835 | Think of the former as the "blank slate" for implementing a site architecture you've designed more or less from the ground up. MVC provides a mechanism for designing a site around a pre-determined "pattern" of application access, if that makes sense. There's more technical detail to it than that, to be sure, but that's the nickel tour for the purposes of the question.
5836 |
5837 | **Source:** _stackoverflow.com_
5838 |
5839 | #### Q7: What is a postback? ⭐⭐
5840 | **Answer:**
5841 | A **postback** originates from the client browser. Usually one of the controls on the page will be manipulated by the user (a button clicked or dropdown changed, etc), and this control will initiate a postback. The state of this control, plus all other controls on the page (known as the View State) is Posted Back to the web server.
5842 |
5843 | **Source:** _stackoverflow.com_
5844 |
5845 | #### Q8: What is ViewState? ⭐⭐
5846 | **Answer:**
5847 | **View State** is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.
5848 |
5849 | A web application is stateless. That means that a new instance of a page is created every time when we make a request to the server to get the page and after the round trip our page has been lost immediately
5850 |
5851 | **Source:** _c-sharpcorner.com_
5852 |
5853 | #### Q9: What exactly is an application pool? What is its purpose? ⭐⭐
5854 | **Answer:**
5855 | **Application pools** allow you to isolate your applications from one another, even if they are running on the same server. This way, if there is an error in one app, it won't take down other applications.
5856 |
5857 | Additionally, applications pools allow you to separate different apps which require different levels of security.
5858 |
5859 | **Source:** _stackoverflow.com_
5860 |
5861 | #### Q10: Explain Middleware in ASP.NET Core? ⭐⭐⭐
5862 | **Answer:**
5863 | Middleware is actually sequential series of delegates (piece of code), that can either short-circuit or pass on the HTTP request to next delegate. These are known as middleware, a concept well known to people who worked with Node.js.
5864 |
5865 | Piece of your middleware can do one of the following:
5866 |
5867 | * Handle an incoming HTTP request by generating an HTTP response (maybe your authentication or authorization middleware will stop the request early and immediately create response)
5868 | * Process the incoming request, change it and pass it to the next middleware in the pipeline
5869 | * Process the outgoing response, change it and pass it on to next middleware in the pipeline or directly to the ASP.NET Core web server
5870 |
5871 | **Source:** _talkingdotnet.com_
5872 |
5873 | #### Q11: What are the different types of caching? ⭐⭐⭐
5874 | **Answer:**
5875 | ASP.NET has 3 kinds of caching :
5876 |
5877 | 1. Output Caching,
5878 | 2. Fragment Caching,
5879 | 3. Data Caching.
5880 |
5881 | **Source:** _guru99.com_
5882 |
5883 | #### Q12: How long the items in ViewState exists? ⭐⭐⭐
5884 | **Answer:**
5885 | They exist for the life of the current page.
5886 |
5887 | **Source:** _guru99.com_
5888 |
5889 | #### Q13: In which event of page cycle is the ViewState available? ⭐⭐⭐
5890 | **Answer:**
5891 | After the Init() and before the Page_Load().
5892 |
5893 | **Source:** _guru99.com_
5894 |
5895 | #### Q14: What are the sub types of ActionResult? ⭐⭐⭐
5896 | **Answer:**
5897 | ActionResult is used to represent the action method result. Below are the subtypes of ActionResult:
5898 |
5899 | * ViewResult
5900 | * PartialViewResult
5901 | * RedirectToRouteResult
5902 | * RedirectResult
5903 | * JavascriptResult
5904 | * JSONResult
5905 | * FileResult
5906 | * HTTPStatusCodeResult
5907 |
5908 | **Source:** _medium.com_
5909 |
5910 | #### Q15: What is the difference between Server.Transfer and Response.Redirect? ⭐⭐⭐
5911 | **Answer:**
5912 | In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.
5913 |
5914 | Response.Redirect is used to redirect the user's browser to another page or site. It performs trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.
5915 |
5916 | **Source:** _guru99.com_
5917 |
5918 | #### Q16: How can we prevent browser from caching an ASPX page? ⭐⭐⭐
5919 | **Answer:**
5920 | We can SetNoStore on HttpCachePolicy object exposed by the Response object's Cache property:
5921 |
5922 | ```csharp
5923 | Response.Cache.SetNoStore();
5924 | Response.Write(DateTime.Now.ToLongTimeString ());
5925 | ```
5926 |
5927 | **Source:** _guru99.com_
5928 |
5929 | #### Q17: What are the event handlers that we can have in Global.asax file? ⭐⭐⭐
5930 | **Answer:**
5931 | * **Application Events:** Application_Start , Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache
5932 |
5933 | * **Session Events:** Session_Start,Session_End
5934 |
5935 | **Source:** _guru99.com_
5936 |
5937 | #### Q18: In which event are the controls fully loaded? ⭐⭐⭐
5938 | **Answer:**
5939 | **Page load** event.
5940 |
5941 | **Source:** _guru99.com_
5942 |
5943 | #### Q19: What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? ⭐⭐⭐
5944 | **Answer:**
5945 | **View state** is a kind of hash map (or at least you can think of it that way) that ASP.NET uses to store all the temporary information about a page - like what options are currently chosen in each select box, what values are there in each text box, which panel are open, etc. You can also use it to store any arbitrary information.
5946 |
5947 | The entire map is serialized and encoded and kept in a _hidden variable_ (__VIEWSTATE form field) that's posted back to the server whenever you take any action on the page that requires a server round trip. This is how you can access the values on the controls from the server code. If you change any value in the server code, that change is made in the view state and sent back to the browser.
5948 |
5949 | Just be careful about how much information you store in the view state, though... it can quickly become bloated and slow to transfer each time to the server and back.
5950 |
5951 | It's not encrypted at all. Just base encoded, which easily reversible.
5952 |
5953 | **Source:** _stackoverflow.com_
5954 |
5955 | #### Q20: What exactly is the difference between .NET Core and ASP.NET Core? ⭐⭐⭐
5956 | **Answer:**
5957 | **.NET Core** is a runtime. It can execute applications that are built for it.
5958 |
5959 | **ASP.NET Core** is a collection of libraries that form a Framework for building web applications. ASP.NET Core libraries can be used on both .NET Core and the "Full .NET Framework" (what has shipped with windows for many years).
5960 |
5961 | **Source:** _stackoverflow.com_
5962 |
5963 | #### Q21: What are the different Session state management options available in ASP.NET? ⭐⭐⭐⭐
5964 | **Answer:**
5965 | Read Full Answer on 👉 FullStack.Cafe
5966 |
5967 | #### Q22: What is the difference between web config and machine config? ⭐⭐⭐⭐
5968 | **Answer:**
5969 | Read Full Answer on 👉 FullStack.Cafe
5970 |
5971 | #### Q23: List the major built-in objects in ASP.NET? ⭐⭐⭐⭐
5972 | **Answer:**
5973 | Read Full Answer on 👉 FullStack.Cafe
5974 |
5975 | #### Q24: What are the different types of cookies in ASP.NET? ⭐⭐⭐⭐
5976 | **Answer:**
5977 | Read Full Answer on 👉 FullStack.Cafe
5978 |
5979 | #### Q25: What is Katana? ⭐⭐⭐⭐
5980 | **Answer:**
5981 | Read Full Answer on 👉 FullStack.Cafe
5982 |
5983 | #### Q26: How to choose between ASP.NET 4.x and ASP.NET Core? ⭐⭐⭐⭐
5984 | **Answer:**
5985 | Read Full Answer on 👉 FullStack.Cafe
5986 |
5987 | #### Q27: What is an HttpHandler in ASP.NET? Why and how is it used? ⭐⭐⭐⭐
5988 | **Answer:**
5989 | Read Full Answer on 👉 FullStack.Cafe
5990 |
5991 | #### Q28: What is the difference between and ? ⭐⭐⭐⭐
5992 | **Answer:**
5993 | Read Full Answer on 👉 FullStack.Cafe
5994 |
5995 | #### Q29: What is HttpModule in ASP.Net? ⭐⭐⭐⭐
5996 | **Answer:**
5997 | Read Full Answer on 👉 FullStack.Cafe
5998 |
5999 | #### Q30: Name some ASP.NET WebForms disadvantages over MVC? ⭐⭐⭐⭐⭐
6000 | **Answer:**
6001 | Read Full Answer on 👉 FullStack.Cafe
6002 |
6003 | #### Q31: What exactly is OWIN and what problems does it solve? ⭐⭐⭐⭐⭐
6004 | **Answer:**
6005 | Read Full Answer on 👉 FullStack.Cafe
6006 |
6007 | #### Q32: Are static class instances unique to a request or a server in ASP.NET? ⭐⭐⭐⭐⭐
6008 | **Details:**
6009 | On an ASP.NET website, are static classes unique to each web request, or are they instantiated whenever needed and GCed whenever the GC decides to disposed of them?
6010 |
6011 | **Answer:**
6012 | Read Full Answer on 👉 FullStack.Cafe
6013 |
6014 | #### Q33: What are the Advantages of Using ASP.NET Web API? ⭐⭐
6015 | **Answer:**
6016 | Using ASP.NET Web API has a number of advantages, but core of the advantages are:
6017 |
6018 | * It works the HTTP way using standard HTTP verbs like `GET`, `POST`, `PUT`, `DELETE`, etc. for all CRUD operations
6019 | * Complete support for routing
6020 | * Response generated in JSON or XML format using `MediaTypeFormatter`
6021 | * It has the ability to be hosted in IIS as well as self-host outside of IIS
6022 | * Supports Model binding and Validation
6023 | * Support for OData
6024 |
6025 | **Source:** _codeproject.com_
6026 |
6027 | #### Q34: Compare WCF vs ASP.NET Web API? ⭐⭐⭐
6028 | **Answer:**
6029 | * **Windows Communication Foundation** is designed to exchange standard SOAP-based messages using variety of transport protocols like HTTP, TCP, NamedPipes or MSMQ, etc.
6030 | * On the other hand, **ASP.NET API** is a framework for building non-SOAP based services over HTTP only.
6031 |
6032 | **Source:** _codeproject.com_
6033 |
6034 | #### Q35: What's the difference between REST & RESTful? ⭐⭐⭐
6035 | **Answer:**
6036 | * Representational state transfer (REST) is a style of software architecture. As described in a dissertation by Roy Fielding, REST is an "architectural style" that basically exploits the existing technology and protocols of the Web.
6037 | * RESTful is typically used to refer to web services implementing such an architecture.
6038 |
6039 | **Source:** _stackoverflow.com_
6040 |
6041 | #### Q36: What's the difference between OpenID and OAuth? ⭐⭐⭐⭐
6042 | **Answer:**
6043 | Read Full Answer on 👉 FullStack.Cafe
6044 |
6045 | #### Q37: Explain the difference between WCF, Web API, WCF REST and Web Service? ⭐⭐⭐⭐⭐
6046 | **Answer:**
6047 | Read Full Answer on 👉 FullStack.Cafe
6048 |
6049 | ## [[⬆]](#toc) 39 Advanced React Interview Questions You Must Clarify (2020 Update)
6050 | > Originally published on 👉 39 Advanced React Interview Questions You Must Clarify (2020 Update) | FullStack.Cafe
6051 |
6052 | #### Q1: What is virtual DOM? ⭐
6053 | **Answer:**
6054 | **The virtual DOM (VDOM)** is an in-memory representation of Real DOM. The representation of a UI is kept in memory and synced with the “real” DOM. It’s a step that happens between the render function being called and the displaying of elements on the screen. This entire process is called reconciliation.
6055 |
6056 | **Source:** _github.com/sudheerj_
6057 |
6058 | #### Q2: What are the differences between a class component and functional component? ⭐⭐
6059 | **Answer:**
6060 | - **Class components** allows you to use additional features such as local state and lifecycle hooks. Also, to enable your component to have direct access to your store and thus holds state.
6061 |
6062 | - When your component just receives props and renders them to the page, this is a **stateless component**, for which a pure function can be used. These are also called dumb components or presentational components.
6063 |
6064 | **Source:** _github.com/Pau1fitz_
6065 |
6066 | #### Q3: What are refs used for in React? ⭐⭐
6067 | **Answer:**
6068 | *Refs* are an escape hatch which allow you to get direct access to a DOM element or an instance of a component. In order to use them you add a ref attribute to your component whose value is a callback function which will receive the underlying DOM element or the mounted instance of the component as its first argument.
6069 |
6070 | ```js
6071 | class UnControlledForm extends Component {
6072 | handleSubmit = () => {
6073 | console.log("Input Value: ", this.input.value)
6074 | }
6075 | render () {
6076 | return (
6077 |
6083 | )
6084 | }
6085 | }
6086 | ```
6087 | Above notice that our input field has a ref attribute whose value is a function. That function receives the actual DOM element of input which we then put on the instance in order to have access to it inside of the handleSubmit function.
6088 |
6089 | It’s often misconstrued that you need to use a class component in order to use refs, but refs can also be used with functional components by leveraging closures in JavaScript.
6090 |
6091 | ```js
6092 | function CustomForm ({handleSubmit}) {
6093 | let inputElement
6094 | return (
6095 |
6101 | )
6102 | }
6103 | ```
6104 |
6105 | **Source:** _github.com/Pau1fitz_
6106 |
6107 | #### Q4: Describe how events are handled in React. ⭐⭐
6108 | **Answer:**
6109 | In order to solve cross browser compatibility issues, your event handlers in React will be passed instances of SyntheticEvent, which is React’s cross-browser wrapper around the browser’s native event. These synthetic events have the same interface as native events you’re used to, except they work identically across all browsers.
6110 |
6111 | What’s mildly interesting is that React doesn’t actually attach events to the child nodes themselves. React will listen to all events at the top level using a single event listener. This is good for performance and it also means that React doesn’t need to worry about keeping track of event listeners when updating the DOM.
6112 |
6113 | **Source:** _tylermcginnis.com_
6114 |
6115 | #### Q5: What is the difference between state and props? ⭐⭐
6116 | **Answer:**
6117 | Both **props** and **state** are plain JavaScript objects. While both of them hold information that influences the output of render, they are different in their functionality with respect to component. i.e,
6118 | * Props get passed to the component similar to function parameters
6119 | * state is managed within the component similar to variables declared within a function.
6120 |
6121 | **Source:** _https://github.com/sudheerj_
6122 |
6123 | #### Q6: How to create refs? ⭐⭐
6124 | **Answer:**
6125 | **Refs** are created using `React.createRef()` method and attached to React elements via the ref attribute. In order to use refs throughout the component, just assign the ref to the instance property with in constructor.
6126 | ```js
6127 | class MyComponent extends React.Component {
6128 | constructor(props) {
6129 | super(props);
6130 | this.myRef = React.createRef();
6131 | }
6132 | render() {
6133 | return
;
6134 | }
6135 | }
6136 | ```
6137 | And:
6138 | ```js
6139 | class UserForm extends Component {
6140 | handleSubmit = () => {
6141 | console.log("Input Value is: ", this.input.value)
6142 | }
6143 | render () {
6144 | return (
6145 |
6151 | )
6152 | }
6153 | }
6154 | ```
6155 | We can also use it in functional components with the help of closures.
6156 |
6157 | **Source:** _github.com/sudheerj_
6158 |
6159 | #### Q7: What are Higher-Order components? ⭐⭐
6160 | **Answer:**
6161 | A higher-order component **(HOC)** is a function that takes a component and returns a new component. Basically, it’s a pattern that is derived from React’s compositional nature
6162 | We call them as **“pure’ components”** because they can accept any dynamically provided child component but they won’t modify or copy any behavior from their input components.
6163 | ```js
6164 | const EnhancedComponent = higherOrderComponent(WrappedComponent);
6165 | ```
6166 | HOC can be used for many use cases as below,
6167 |
6168 | 1. Code reuse, logic and bootstrap abstraction
6169 | 2. Render High jacking
6170 | 3. State abstraction and manipulation
6171 | 4. Props manipulation
6172 |
6173 | **Source:** _github.com/sudheerj_
6174 |
6175 | #### Q8: What is the purpose of using super constructor with props argument? ⭐⭐
6176 | **Answer:**
6177 | A child class constructor cannot make use of **this** reference until `super()` method has been called. The same applies for ES6 sub-classes as well. The main reason of passing props parameter to super() call is to access this.props in your child constructors.
6178 |
6179 | **Passing props:**
6180 | ```js
6181 | class MyComponent extends React.Component {
6182 | constructor(props) {
6183 | super(props);
6184 | console.log(this.props); // Prints { name: 'sudheer',age: 30 }
6185 | }
6186 | }
6187 | ```
6188 | **Not passing props:**
6189 | ```js
6190 | class MyComponent extends React.Component {
6191 | constructor(props) {
6192 | super();
6193 | console.log(this.props); // Prints undefined
6194 | // But Props parameter is still available
6195 | console.log(props); // Prints { name: 'sudheer',age: 30 }
6196 | }
6197 |
6198 | render() {
6199 | // No difference outside constructor
6200 | console.log(this.props) // Prints { name: 'sudheer',age: 30 }
6201 | }
6202 | }
6203 | ```
6204 |
6205 | The above code snippets reveals that this.props behavior is different only with in the constructor. It would be same outside the constructor.
6206 |
6207 | **Source:** _github.com/sudheerj_
6208 |
6209 | #### Q9: What are controlled components? ⭐⭐⭐
6210 | **Answer:**
6211 | In HTML, form elements such as ` `, `