Interview Questions Flashcards

asp.net, tsql, psql, entity framework, angularjs (71 cards)

1
Q

What is ASP.NET MVC?

A

ASP.NET MVC is a web application Framework. It is light weight and highly testable Framework. MVC separates application into three components — Model, View and Controller.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can you explain Model, Controller and View in MVC?

A

Model — It’s a business entity and it is used to represent the application data.

Controller — Request sent by the user always scatters through controller and it’s responsibility is to redirect to the specific view using View() method.

View — It’s the presentation layer of MVC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Can you explain the page life cycle of MVC?

A

App initialization

Routing

Instantiate and execute controller

Locate and invoke controller action

Instantiate and render view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the advantages of MVC over ASP.NET?

A

Provides a clean separation of concerns among UI (Presentation layer), model (Transfer objects/Domain Objects/Entities) and Business Logic (Controller).

Easy to UNIT Test.

Improved reusability of model and views. We can have multiple views which can point to the same model and vice versa.

Improved structuring of the code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Separation of Concerns in ASP.NET MVC?

A

It’s is the process of breaking the program into various distinct features which overlaps in functionality as little as possible. MVC pattern concerns on separating the content from presentation and data-processing from content.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Razor View Engine?

A

Razor is the first major update to render HTML in MVC 3. Razor was designed specifically for view engine syntax. Main focus of this would be to simplify and code-focused templating for HTML generation. Below is the sample of using Razor:

@model MvcMusicStore.Models.Customer

@{ViewBag.Title = “Get Customers”;}

<div class="”cust”"> <h3><em>@Model.CustomerName</em> </h3></div>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the use of ViewModel in MVC?

A

ViewModel is a plain class with properties, which is used to bind it to strongly typed view. ViewModel can have the validation rules defined for its properties using data annotations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What you mean by Routing in MVC?

A

Routing is a pattern matching mechanism of incoming requests to the URL patterns which are registered in route table. Class — “UrlRoutingModule” is used for the same process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are Actions in MVC?

A

Actions are the methods in Controller class which is responsible for returning the view or json data. Action will mainly have return type — “ActionResult” and it will be invoked from method — “InvokeAction()” called by controller.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain JSON Binding?

A

JavaScript Object Notation (JSON) binding support started from MVC3 onwards via the new JsonValueProviderFactory, which allows the action methods to accept and model-bind data in JSON format. This is useful in Ajax scenarios like client templates and data binding that need to post data back to the server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain Bundle.Config in MVC4?

A

“BundleConfig.cs” in MVC4 is used to register the bundles by the bundling and minification system. Many bundles are added by default including jQuery libraries like — jquery.validate, Modernizr, and default CSS references.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How route table has been created in ASP.NET MVC?

A

Method — “RegisterRoutes()” is used for registering the routes which will be added in “Application_Start()” method of global.asax file, which is fired when the application is loaded or started.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which are the important namespaces used in MVC?

A

System.Web.Mvc

System.Web.Mvc.Ajax

System.Web.Mvc.Html

System.Web.Mvc.Async

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is ViewData?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between ViewBag and ViewData in MVC?

A

ViewBag is a wrapper around ViewData, which allows to create dynamic properties. Advantage of viewbag over viewdata will be –

In ViewBag no need to typecast the objects as in ViewData.

ViewBag will take advantage of dynamic keyword which is introduced in version 4.0. But before using ViewBag we have to keep in mind that ViewBag is slower than ViewData.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Explain TempData in MVC?

A

TempData is again a key, value pair as ViewData. This is derived from “TempDataDictionary” class. TempData is used when the data is to be used in two consecutive requests, this could be between the actions or between the controllers. This requires typecasting in view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are HTML Helpers in MVC?

A

HTML Helpers are like controls in traditional web forms. But HTML helpers are more lightweight compared to web controls as it does not hold viewstate and events.

HTML Helpers returns the HTML string which can be directly rendered to HTML page. Custom HTML Helpers also can be created by overriding “HtmlHelper” class.

@Html.ActionLink(“Create New”, “Create”) would generate anchor tag <a>Create New</a>.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are AJAX Helpers in MVC?

A

AJAX Helpers are used to create AJAX enabled elements like as Ajax enabled forms and links which performs the request asynchronously and these are extension methods of AJAXHelper class which exists in namespace — System.Web.Mvc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is Layout in MVC?

A

Layout pages are similar to master pages in traditional web forms. This is used to set the common look across multiple pages. In each child page we can find — /p>

@{

Layout = “~/Views/Shared/TestLayout1.cshtml”;

}

This indicates child page uses TestLayout page as it’s master page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Can you explain RenderBody and RenderPage in MVC?

A

RenderBody is like ContentPlaceHolder in web forms. This will exist in layout page and it will render the child pages/views. Layout page will have only one RenderBody() method. RenderPage also exists in Layout page and multiple RenderPage() can be there in Layout page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is ViewStart Page in MVC?

A

This page is used to make sure common layout page will be used for multiple views. Code written in this file will be executed first when application is being loaded.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Explain the methods used to render the views in MVC?

A

Below are the methods used to render the views from action -

View() — To return the view from action.

PartialView() — To return the partial view from action.

RedirectToAction() — To Redirect to different action which can be in same controller or in different controller.

Redirect() — Similar to “Response.Redirect()” in webforms, used to redirect to specified URL.

RedirectToRoute() — Redirect to action from the specified URL but URL in the route table has been matched.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How we can call a JavaScript function on the change of a Dropdown List in MVC?

A

function DrpIndexChanged() { }

Invoke the method:

x.SelectedProduct, new SelectList(Model.Customers, “Value”, “Text”), “Please Select a Customer”, new { id = “ddlCustomers”, onchange=” DrpIndexChanged ()” })%>

<%=Html.DropDownList(“title”, Model.Titleitems, new{@onchange = “YourJsFuncHere()”} )%>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are Validation Annotations?

A

Data annotations are attributes which can be found in the “System.ComponentModel.DataAnnotations” namespace. These attributes will be used for server-side validation and client-side validation is also supported. Four attributes — Required, String Length, Regular Expression and Range are used to cover the common validation scenarios.

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

    [Required]
    [StringLength(10)]
    public string Name { get; set; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Why to use Html.Partial in MVC?
This method is used to render the specified partial view as an HTML string. This method does not depend on any action methods. We can use this like below – @Html.Partial(“TestPartialView”)
26
What is RouteConfig.cs in MVC 4?
“RouteConfig.cs” holds the routing configuration for MVC. RouteConfig will be initialized on Application_Start event registered in Global.asax.
27
What are Scaffold templates in MVC?
Scaffolding in ASP.NET MVC is used to generate the Controllers,Model and Views for create, read, update, and delete (CRUD) functionality in an application. The scaffolding will be knowing the naming conventions used for models and controllers and views.
28
Explain the types of Scaffoldings.
Scaffolding is a technique used by many MVC frameworks like ASP.NET MVC, Ruby on Rails, Cake PHP and Node. JS etc., to generate code for basic CRUD (create, read, update, and delete) operations against your database effectively.
29
Can a view be shared across multiple controllers? If Yes, How we can do that?
Yes, we can share a view across multiple controllers. We can put the view in the “Shared” folder. When we create a new MVC Project we can see the Layout page will be added in the shared folder, which is because it is used by multiple child pages.
30
What are the possible Razor view extensions?
.cshtml — In C# programming language this extension will be used. .vbhtml — In VB programming language this extension will be used.
31
What is PartialView in MVC?
PartialView is similar to UserControls in traditional web forms. For re-usability purpose partial views are used. Since it’s been shared with multiple views these are kept in shared folder. Partial Views can be rendered in following ways – Html.Partial() Html.RenderPartial()
32
Explain what is T-SQL?
T-SQL stands for Transact-Structured Query Language, which is an extension of SQL functionality supported by Microsoft SQL Server and Sybase ASE.
33
Explain what are the differences between SQL and T-SQL?
The difference between T-SQL and SQL is that SQL is a query language to operate on sets, while TSQL is a proprietary procedural language used by MS SQL Server. Also, T-SQL has a different implementation of DELETE and UPDATE than SQL.
34
Please name at least five commands which can manipulate text in the T-SQL code. For example, replace a text string, obtain a portion of the text, etc.
* LEFT(character_expression, integer_expression ) – It returns left part of a character expression with the specified number of characters. * CHARINDEX( findTextData, textData, [startingPosition] ) – It returns starting position of an expression in a character string, and starting position is optional. * REPLACE( textData, findTextData, replaceWithTextData ) – It replaces a new value for occurrences of text found in the string. * REVERSE( character_expression ) – It returns reverse of a character expression. * LEN( textData ) – It returns the length of the string, excluding trailing blanks. * LOWER ( character_expression ) – After converting an uppercase character to lowercase it will return a character expression. * LTRIM( textData) – Leading blanks will be removed. * PATINDEX( findTextData, textData ) – It returns the starting position integer value of text found in the string. * REPLICATE(character_expression, integer_expression ) – It repeats a character expression for a specified number of times. * RTRIM( textData) – Removes trailing blanks. SPACE( number of spaces ) – It repeats space value specified number of times. * STUFF( textData, start, length, insert text data ) – It deletes a specified length of characters and inserts another set of characters at a specified starting point. * SUBSTRING( textData, startPosition, length ) – It returns portion of the string. * UPPER( character_expression ) – It returns a character expression with lowercase character to uppercase.
35
Mention how tsql statements can be written and submitted to the Database engine?
Tsql statements can be written and submitted to the Database engine in following ways, By using the SQLcmd Utility By using the SQL Server Management Studio By connecting from an application that you create
36
Mention what is ‘GO’ in T-SQL?
‘GO’ is not a Transact-SQL statement but a batch separator. It is a command identified by the sqlcmd and osql utilities and SQL Server Management Studio Code editor. SQL Server utilities read “GO” as a signal that they should send the current batch of TSQL statements to an instance of SQL Server.o
37
Mention difference between DELETE statement and TRUNCATE statement?
With the use of DELETE and TRUNCATE command, all data will be lost in a table. The difference between DELETE statement and TRUNCATE statement is that, •DELETE is used for conditional removal of data records from Tables. These operations are logged. •TRUNCATE is used for unconditional removal of data records from Tables. Truncate Operations are not logged.
38
When to use COALESCE() & ISNULL() Functions?
The NULLability of result expression is different for ISNULL and COALESCE. The ISNULL return value is always considered NOT NULLable (assuming the return value is a non-nullable one) whereas COALESCE is not. So the expressions ISNULL(NULL, 1) and COALESCE(NULL, 1) although equivalent has different NULLability values. This makes a difference if you are using these expressions in computed columns and creating key constraints or making return value of a scalar UDF deterministic so that it can be indexed.
39
Mention what is sub-query?
A sub-query is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved. A sub-query can be used with the statements like Update, select, delete and insert with the operators like =, >, =,<=, etc
40
Mention new error handling commands which are introduced with the SQL Server 2005 and beyond? What commands did they replace? How are they command used?
The new commands introduce with SQL Server 2005 are TRY and CATCH. Though they do not replace directly any specific command, but in many aspects TRY and CATCH can be used instead of RAISERROR. The TRY block covers business logic whereas the CATCH logic is for capturing the error.
41
Mention what is TOP in TSQL?
TOP limits the rows returned in a query result set to a specified number of rows or percentage of rows in SQL Server. When TOP is used in combination with the ORDER BY clause, the result set is limited to the first N number of ordered rows. Otherwise, it retrieves the first N number of rows in an undefined order.
42
Mention how does a local variable is defined using T-SQL?
A local variable is defined using TSQL by using statement “DECLARE” and the name of the local variable should begin with “@” sign as the first character of its name. For example, integer CNT we will define local variable as, DECLARE @CNT INT
43
Mention what are dynamic queries in T-SQL?
Dynamic queries in T-SQL are those queries designed on the fly/ at run time using variables or using CTE or other sources. We use EXECUTE function or SP_EXECUTESQL Stored Procedure to execute such queries.
44
Mention what are the maximum number of rows that can be constructed by inserting rows directly in VALUE list?
The maximum number of rows that can be constructed by inserting rows directly in VALUE list is 1000.
45
Mention what is TOP in TSQL?
TOP limits the rows returned in a query result set to a specified number of rows or percentage of rows in SQL Server. When TOP is used in combination with the ORDERBY clause, the result set is limited to the first N number of ordered rows. Otherwise, it retrieves the first N number of rows in an undefined order.
46
Mention what are the Join Types in TSQL?
``` Inner join Outer join Left outer join Right outer join Left outer join with Exclusions Right outer join with Exclusions Full outer join Full outer joins with Exclusions Cross join ```
47
Mention what are the T String functions available in TSQL?
``` Left Right Ltrim Rtrim Substring Replace Stuff ```
48
Mention what is the syntax used for partition in TSQL?
[ database_name. ] $PARTITION.partition_function_name(expression) 18) Mention what is the syntax for using SQL_Variant_Property? The syntax for using SQL_Variant_Property is, SQL_Variant_Property (expression, property)
49
Mention what is uncommittable transactions?
When an error occurs in a transaction within a TRY block, and if the error is not serious it enters into a status open and Uncommittable. In uncommittable state, the transactions cannot perform any action that would generate a write to the transaction log.
50
Mention what are the limitations of IDENTITY column?
The limitations of the IDENTITY column is that column values cannot be updated once generated. Also, it may require to specify this column as a PRIMARY KEY, as such, there is a possibility of duplication of values within a table. Identity property is applicable for integer based column only.
51
What is Entity Framework?
Microsoft Entity Framework (EF) is an Object Relational Mapping framework that provides an abstraction layer (a kind of mapping) between two incompatible systems (i.e. Object oriented programming languages with Relational databases). It enables us to interact with relational data in an object oriented way, meaning we can retrieve and manipulate data as strongly typed objects using LINQ queries. Application -- DRM Interface - Entity Framework - Entity Data Model (EDM) - ADO.NET Provider - Database
52
What are the advantages of using Entity Framework?
Separation of Concerns (SoC) - a design principle for separating a computer program into distinct sections, such that each section addresses a separate concern. DB - EF - Reposiory - Controller - VIew LINQ is used as a common syntax for all object queries. Code Auto-Generation.
53
Entity Framework Features
Entity Framework is a Microsoft tool. Entity Framework is being developed as an Open Source product. Entity Framework is no longer tied or dependent to the .NET release cycle. Works with any relational database with valid Entity Framework provider. SQL command generation from LINQ to Entities. Entity Framework will create parameterized queries. Tracks changes to in-memory objects. Allows to insert, update and delete command generation. Works with a visual model or with your own classes. Entity Framework has stored Procedure Support.
54
Entity Framework uses DbContext, How is it different from Object Context?
DbContext can be used for code first while Object Context doesn’t. It exposes the most commonly used features of ObjectContext. A DbContext instance represents a session with the database and can be used to query and save instances of your entities
55
Why DB Context models object disposal is important in Entity Framework?
Until it’s disposed, it will be holding resources that aren’t in. If not disposed then Garbage collector will free the space but in some instance it holds up. Calling dispose method to clear memory.
56
What is Angular?
Angular is an open-source front-end web framework. It is one of the most popular JavaScript frameworks that is mainly maintained by Google. It provides a platform for easy development of web-based applications and empowers the front end developers in curating cross-platform applications. It integrates powerful features like declarative templates, an end to end tooling, dependency injection and various other best practices that smoothens the development path
57
What are the advantages of using Angular?
It supports two-way data-binding It follows MVC pattern architecture It supports static template and Angular template You can add a custom directive It also supports RESTfull services Validations are supported Client and server communication is facilitated Support for dependency injection Has strong features like Event Handlers, Animation, etc.
58
What is Angular mainly used for?
Angular is typically used for the development of SPA which stands for Single Page Applications. Angular provides a set of ready-to-use modules that simplify the development of single page applications. Not only this, with features like built-in data streaming, type safety, and a modular CLI, Angular is regarded as a full-fledged web framework.
59
What are Angular expressions?
Angular expressions are code snippets that are usually placed in binding such as {{ expression }} similar to JavaScript. These expressions are used to bind application data to HTML Syntax: {{ expression }}
60
What are templates in Angular?
Templates in Angular are written with HTML that contains Angular-specific elements and attributes. These templates are combined with information coming from the model and controller which are further rendered to provide the dynamic view to the user.
61
What is the difference between an Annotation and a Decorator in Angular?
Annotations in angular are “only” metadata set of the class using the Reflect Metadata library. They are used to create an “annotation” array. On the other hand, decorators are the design patterns that are used for separating decoration or modification of a class without actually altering the original source code.
62
What do you understand by controllers in Angular?
Controllers are JavaScript functions which provide data and logic to HTML UI. As the name suggests, they control how data flows from the server to HTML UI.
63
What is scope in Angular?
Scope in Angular is an object that refers to the application model. It is an execution context for expressions. Scopes are arranged in a hierarchical structure which mimics the DOM structure of the application. Scopes can watch expressions and propagate events.
64
What are directives in Angular?
A core feature of Angular, directives are attributes that allow you to write new HTML syntax, specific to your application. They are essentially functions that execute when the Angular compiler finds them in the DOM. The Angular directives are segregated into 3 parts: Component Directives Structural Directives Attribute Directives
65
What is data binding in Angular ?
n Angular, data binding is one of the most powerful and important features that allow you to define the communication between the component and DOM(Document Object Model). It basically simplifies the process of defining interactive applications without having to worry about pushing and pulling data between your view or template and component. In Angular, there are four forms of data binding: String Interpolation Property Binding Event Binding Two-Way Data Binding
66
Explain Components, Modules and Services in Angular
Components: component is responsible for rendering a view and handling user interactions with the view. Modules: A module is a container that holds a collection of connected components. Every angular app contains at least one module, which we refer to as the app module. We may want to divide our modules into smaller, more maintainable modules as our application expands. Service: Angular services are singleton objects that are instantiated only once during an application’s lifetime. They include methods for preserving data during the life of an application, i.e., data is not refreshed and is always available.
67
Inner Join
Returns records that have matching values in both tables
68
Outer join
returns a set of records (or rows) that include what an inner join would return but also includes other rows for which no corresponding match is found in the other table.
69
Left Outer join
Return all records from the left table, and the matched records from the right table
70
Righter Outer join
Return all records from the right table, and the matched records from the left table
71
Full outer join
Return all records when there is a match in either left or right table