Infosys questions Flashcards
What is a candidate key?
Minimal set of columns in a table that every other column depends on
How do you send information from the controller to the view in MVC?
by passing an object of the model class to the View.
What is the difference between a function and stored procedure?
Basic Differences between Stored Procedure and Function in SQL Server. The function must return a value but in Stored Procedure it is optional. Even a procedure can return zero or n values. Functions can have only input parameters for it whereas Procedures can have input or output parameters.
What is a primary key and foreign key and how are they used?
Primary key: Unique identifier for a row in a table
Foreign key: A set of columns which hold the values of some primary key to establish a relationship to another row
In MVC, how would you add another record in your database?
from the controller (which pulls from your dbrepo), to your models, to the database
What is the difference between Union and Union All?
The only difference between Union and Union All is that Union extracts the rows that are being specified in the query while Union All extracts all the rows including the duplicates (repeated values) from both the queries.
What is a join?
combines columns from one or more tables into a new table.
Difference Between Delete and Truncate
DELETE: It removes rows one at a time.
TRUNCATE: It removes all rows in a table by deallocating the pages that are used to store the table data
What are temporary tables?
A temporary table is a base table that is not stored in the database but instead exists only while the database session in which it was created is active
What are temporary tables used for?
lets you store and process intermediate results by using the same selection, update, and join capabilities that you can use with typical SQL Server tables.
how do you create a temporary table?
SELECT INTO statement
What are global variables and table variables
A global variable is a named memory variable that you access through SQL statements.
The table variable is a special type of the local variable that helps to store data temporarily
How to find the highest salary of a given table, then the 2nd highest salary, then the 100th.
To find the highest:
select * from employee where salary=(select Max(salary) from employee);
2nd highest:
SELECT name, MAX(salary) AS salary
FROM employee
WHERE salary ID = 2
100 highest:
SELECT name, MAX(salary) AS salary
FROM employee
WHERE salary ID = 100
Too much white space in front of my string, how to remove it? (SQL)
use trim() , ltrim() or rtrim() to remove it.
How to do angular validation, client or server?
AngularJS offers client-side form validation.
AngularJS monitors the state of the form and input fields (input, textarea, select), and lets you notify the user about the current state.
What is the difference between an inner and outer join?
The major difference between inner and outer joins is that inner joins result in the intersection of two tables, whereas outer joins result in the union of two tables.
What header you use to send data to api
HTTP POST
What header you use to get data from api
HTTP GET
What is MVC workflow
HTTP request comes to the controller then controller categorized an action, then send request to the Model to get data for the categorized action, then finally send the action to the view and process the view to send as a HTTP response. so the workflow is Controller-Model-View.
What frontend libraries have you used in your recent project
JS, TS, Bootstrap
Can you use two Action Methods in a controller to get the data from same table
yes
What are filters
a custom class where you can write custom logic to execute before or after an action method executes. Filters can be applied to an action method or controller in a declarative or programmatic way.
What type of databases have you worked in
azure, elephant sql
How do you pass values between controller and view in your Application
ViewBag and ViewData serves the same purpose in allowing developers to pass data from controllers to views.
Difference between ViewData and ViewBag
ViewData is derived from the ViewDataDictionary class and is basically a Dictionary object i.e., Keys and Values where Keys are String while Values will be objects.
Data is stored as Object in ViewData.
While retrieving the data it needs to be Type Cast to its original type as the data is stored as the object and it also requires NULL checks while retrieving.
ViewData is used for passing value from Controller to View.
ViewData is available only for Current Request. It will be destroyed on redirection.
ViewBag is a Wrapper built around ViewData.
ViewBag is a dynamic property and it makes use of the C# 4.0 dynamic features.
While retrieving, there is no need for Type Casting data.
ViewBag is used for passing value from Controller to View.
ViewBag is available only for Current Request. It will be destroyed on redirection.
How much Devops do you know
CI/CD, test coverage, unit testing
What are HTTP methods
verbs that tell the server what you want
What is TDD and did you implemented TDD in your projects
Test driven development. Write tests that fail,
Implement code to make tests pass. Yes.
What is routing
routing from one component in your program to another
What are Nested Triggers
actions that automatically execute when a certain database operation is performed, for example, INSERT, DROP, UPDATE
Explain MVC components
Model: Handles data logic. View: It displays the information from the model to the user. Controller: It controls the data flow into a model object and updates the view whenever data changes.
Error Handling in MVC
Try-catch-finally
Overriding OnException method
Using the [HandleError] attribute on actions and controllers
Setting a global exception handling filter
Handling Application_Error event
Extending HandleErrorAttribute
What are the pillars of OOP?
Polymorphism, Inheritance, Abstraction, Encapsulation
What are access modifiers and label them?
private, public, protected, internal, and two combinations: protected-internal and private-protected.
What is the difference between public and protected?
public - can be access by anyone anywhere. protected - can only be accessed from with in the class or any object that inherits off of the class.
What is Entity Framework?
an open-source ORM framework for .NET applications supported by Microsoft. It enables developers to work with data using objects of domain specific classes without focusing on the underlying database tables and columns where this data is stored.
What is managed code?
code whose execution is managed by a runtime.
What is SQL?
Structured Query Language. SQL is used to communicate with a database.
Explain the query for searching an “Employee Table” where I want three employees with their name and employee ID.
SELECT id, name FROM Employee
WHERE ( ( id >= 3 ) );
What is ACID?
ACID refers to the four key properties of a transaction: atomicity, consistency, isolation, and durability.
Explain the query for searching an “Employee Table” where I want three employees with their name and employee ID.
SELECT * FROM Employee
WHERE ( ( id >= 3 ) );
Explain the query for searching an “Employee Table” where I would like to find the top employee based on productivity.
SELECT * FROM Employee WHERE MAX(productivity);
What is a function?
a set of instructions bundled together to achieve a specific outcome.
Which function have you used more and why (Scalar and Tabular)?
Scalar