Infosys questions Flashcards

1
Q

What is a candidate key?

A

Minimal set of columns in a table that every other column depends on

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

How do you send information from the controller to the view in MVC?

A

by passing an object of the model class to the View.

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

What is the difference between a function and stored procedure?

A

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.

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

What is a primary key and foreign key and how are they used?

A

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

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

In MVC, how would you add another record in your database?

A

from the controller (which pulls from your dbrepo), to your models, to the database

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

What is the difference between Union and Union All?

A

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.

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

What is a join?

A

combines columns from one or more tables into a new table.

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

Difference Between Delete and Truncate

A

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

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

What are temporary tables?

A

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

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

What are temporary tables used for?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how do you create a temporary table?

A

SELECT INTO statement

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

What are global variables and table variables

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to find the highest salary of a given table, then the 2nd highest salary, then the 100th.

A

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

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

Too much white space in front of my string, how to remove it? (SQL)

A

use trim() , ltrim() or rtrim() to remove it.

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

How to do angular validation, client or server?

A

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.

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

What is the difference between an inner and outer join?

A

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.

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

What header you use to send data to api

A

HTTP POST

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

What header you use to get data from api

A

HTTP GET

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

What is MVC workflow

A

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.

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

What frontend libraries have you used in your recent project

A

JS, TS, Bootstrap

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

Can you use two Action Methods in a controller to get the data from same table

A

yes

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

What are filters

A

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.

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

What type of databases have you worked in

A

azure, elephant sql

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

How do you pass values between controller and view in your Application

A

ViewBag and ViewData serves the same purpose in allowing developers to pass data from controllers to views.

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

Difference between ViewData and ViewBag

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

How much Devops do you know

A

CI/CD, test coverage, unit testing

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

What are HTTP methods

A

verbs that tell the server what you want

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

What is TDD and did you implemented TDD in your projects

A

Test driven development. Write tests that fail,

Implement code to make tests pass. Yes.

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

What is routing

A

routing from one component in your program to another

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

What are Nested Triggers

A

actions that automatically execute when a certain database operation is performed, for example, INSERT, DROP, UPDATE

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

Explain MVC components

A

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.

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

Error Handling in MVC

A

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

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

What are the pillars of OOP?

A

Polymorphism, Inheritance, Abstraction, Encapsulation

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

What are access modifiers and label them?

A

private, public, protected, internal, and two combinations: protected-internal and private-protected.

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

What is the difference between public and protected?

A
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What is Entity Framework?

A

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.

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

What is managed code?

A

code whose execution is managed by a runtime.

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

What is SQL?

A

Structured Query Language. SQL is used to communicate with a database.

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

Explain the query for searching an “Employee Table” where I want three employees with their name and employee ID.

A

SELECT id, name FROM Employee

WHERE ( ( id >= 3 ) );

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

What is ACID?

A

ACID refers to the four key properties of a transaction: atomicity, consistency, isolation, and durability.

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

Explain the query for searching an “Employee Table” where I want three employees with their name and employee ID.

A

SELECT * FROM Employee

WHERE ( ( id >= 3 ) );

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

Explain the query for searching an “Employee Table” where I would like to find the top employee based on productivity.

A
SELECT * FROM Employee
WHERE MAX(productivity);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

What is a function?

A

a set of instructions bundled together to achieve a specific outcome.

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

Which function have you used more and why (Scalar and Tabular)?

A

Scalar

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

Which function have you used more and why (Scalar and Tabular)?

A

Scalar

46
Q

The functions which return only a single value from an input value are known as a _____.

A

scalar function

47
Q

A table-valued function is a user-defined function that returns data of a table type.

A

Tabular function

48
Q

What is a view?

A

a software class that contains a template and data form and produces a response for the browser. It receives data from the Controller of the MVC and packages it and presents it to the browser for display.

49
Q

What is a primary key?

A

a value, or a combination of few values from the table, uniquely defining each record in this table.

50
Q

What type of key represents the relationship between “Department” and “Employee”?

A

Foreign

51
Q

What is the SELECT and WHERE clause?

A

select row from table where (condition)

52
Q

How do you handle/deal with exceptions in SQL?

A

TRY.. CATCH blocks

53
Q

Give me the steps by steps to consume api service.

A

Create MVC Application. Install HttpClient library from NuGet. Install WebAPI.Client library from NuGet. Create Model Class.

54
Q

‘with’ in SQL?

A

allows us to give a subquery block a name that can be used in multiple places within the main SELECT, INSERT, DELETE or UPDATE SQL query.

55
Q

How do you do unions?

A

UNION clause

56
Q

What did you observe about DbFirst vs ‘the normal way’?

A

freestyle

57
Q

client-side scripting

A

Client-side scripting simply means running scripts, such as JavaScript, on the client device, usually within a browser

58
Q

How do you pass data between components?

A

Parent to Child component: When you define @Input() in the child component it will receive value from the master or parent component.

Child to Parent component: For sharing data from child to parent we need output decorator.

59
Q

How to do LINQ query

A

select, from, where clauses

from s in stringList
where s.Contains(“Tutorials”)
select s;

60
Q

How to use Lambda expression

A

Func square = x => x * x;

61
Q

How do observables work?

A

Emit multiple values over a period of time. Have subscriptions that are cancellable using the unsubscribe() method, which stops the listener from receiving further values.

62
Q

SOLID principles

A
S - Single-responsiblity Principle
O - Open-closed Principle
L - Liskov Substitution Principle
I - Interface Segregation Principle
D - Dependency Inversion Principle

Single-responsibility Principle (SRP) states:

A class should have one and only one reason to change, meaning that a class should have only one job.

Open-closed Principle (OCP) states:

Objects or entities should be open for extension but closed for modification.

Liskov Substitution Principle states:

This means that every subclass or derived class should be substitutable for their base or parent class.

Interface segregation principle states:

A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.

Dependency inversion principle states:

Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions.

63
Q

ACID principles

A

atomicity, consistency, isolation, and durability.

Atomicity
All changes to data are performed as if they are a single operation. That is, all the changes are performed, or none of them are.

Consistency
Data is in a consistent state when a transaction starts and when it ends.

Isolation
The intermediate state of a transaction is invisible to other transactions. As a result, transactions that run concurrently appear to be serialized.

Durability
After a transaction successfully completes, changes to data persist and are not undone, even in the event of a system failure.

64
Q

Why do we even use abstract classes and interfaces?

A

An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to define functionality, not implement it. And whereas a class can extend only one abstract class, it can take advantage of multiple interfaces.

65
Q

Two interfaces with same method name. How can you fix this?

A

There is a conflict

66
Q

How can you make an array hold many different types of data?

A

declare the array as Object.

67
Q

How can you deal with null reference exception?

A

Use Debug. Assert if a value should never be null , to catch the problem earlier than the exception occurs. When you know during development that a method could, but never should return null , you can use Debug.

68
Q

What are interfaces used for in C#.

A

Interfaces help define a contract (agreement or blueprint, however you chose to define it), between your application and other objects. This indicates what sort of methods, properties, and events are exposed by an object.

69
Q

What are transactions in SQL

A

A transaction is a logical unit of work that contains one or more SQL statements

70
Q

Difference between Angular app and MVC app

A

Angular uses components where MVC uses controllers

71
Q

what are Data Annotations

A

the process of labeling the data available in various formats like text, video or images.

72
Q

What is Entity Framework Core?

A

a lightweight, extensible, open source and cross-platform version of the popular Entity Framework data access technology.

73
Q

Write a function to find all null first names and replace with empty string/last name.

A
string[] firstName = new string[] {null, "john", null, "betty"};
string[] lastName = new string[] {"rose", "test", "test1", "oops"};
func test()
{
for(int i = 0; i
74
Q

Explain what Inheritance is and how it is implemented in Object Oriented Programming.

A

The mechanism of basing an object or class upon another object or class, retaining similar implementation

Establishes an “is-a” relationship between objects
Promotes code reusability

In C# the constructors are inherited from parent to child

You can ____ from multiple interfaces but you can only ____ from one class

75
Q

How would you instantiate a static class?

A

A static class cannot be instantiated. All members of a static class are static and are accessed via the class name directly, without creating an instance of the class.

76
Q

What does the sealed keyword do?

A

Applied to: classes, class members

Sealed classes cannot be inherited by other classes

Sealed methods and properties aren’t overridable in
any classes that inherit those members

Similar to the final keyword in java

77
Q

What are indexes in SQL?

A

Indexes are special lookup tables that the database search engine can use to speed up data retrieval. Simply put, an index is a pointer to data in a table.

78
Q

what is JIRA?

A

a proprietary issue tracking product developed by Atlassian that allows bug tracking and agile project management

79
Q

Describe the SQL Normalization forms

A

1NF = Atomic Values, No repeating groups of columns, No duplicate rows

2NF = Has to be 1NF, NO partial dependencies, No composite keys mean you’re 2NF by default

3NF =Has to be 2NF, NO transitive dependencies

80
Q

Explain subqueries in SQL

A

A Subquery or Inner query or a Nested query is a query within another SQL query and embedded within the WHERE clause.

A subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved.

Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the operators like =, , >=, <=, IN, BETWEEN, etc.

81
Q

Explain Angular Lifecycle hooks and their order

A

Lifecycle hooks are timed methods. They differ in when and why they execute. Change detection triggers these methods. They execute depending on the conditions of the current cycle. Angular runs change detection constantly on its data. Lifecycle hooks help manage its effects.

ngOnChanges triggers following the modification of @Input bound class members. Data bound by the @Input() decorator come from an external source. When the external source alters that data in a detectable manner, it passes through the @Input property again.

82
Q

Differences between structs and classes in C#

A

Structs are value types while classes are reference types. Structs can be instantiated without using a new operator. A struct cannot inherit from another struct or class, and it cannot be the base of a class. All structs inherit directly from System.

83
Q

What are the levels of garbage collection?

A

A marking phase that finds and creates a list of all live objects.

A relocating phase that updates the references to the objects that will be compacted.

A compacting phase that reclaims the space occupied by the dead objects and compacts the surviving objects.

84
Q

How does an object progress through those levels of garbage collection?

A

Objects that are not reclaimed in a garbage collection are known as survivors and are promoted to the next generation:

Objects that survive a generation 0 garbage collection are promoted to generation 1.
Objects that survive a generation 1 garbage collection are promoted to generation 2.
Objects that survive a generation 2 garbage collection remain in generation 2.

85
Q

What is dynamic polymorphism

A

a process or mechanism in which a call to an overridden method is to resolve at runtime rather than compile-time.

86
Q

give an example of dynamic polymorphism

A

All cats have tails. Bobcats have short tails.

87
Q

What is object pooling?

A

software creational design pattern that uses a set of initialized objects kept ready to use – a “pool” – rather than allocating and destroying them on demand.

88
Q

What is depth first search?

A

an algorithm for traversing or searching tree or graph data structures.

89
Q

How do you accomplish error handling in C#?

A

testing, debugging

90
Q

What is “finally” used for in C#?

A

The finally block will execute when the try/catch block leaves the execution, no matter what condition cause it. It always executes whether the try block terminates normally or terminates due to an exception. The main purpose of finally block is to release the system resources.

91
Q

How do you do multiple inheritance?

A

implement multiple interfaces in a class.

92
Q

How would you protect routes?

A

using route guards. Angular’s route guards are interfaces which can tell the router whether or not it should allow navigation to a requested route.

93
Q

What are dependencies and how are they managed in Angular?

A

dependencies are imports that a component needs to use that classes methods or variables and angular manages this through dependency inject

94
Q

What are the different types of directives and what do they do?

A

Structural, and attribute directives structural directives change the structure of dom/html page - so things like ngIf, ngFor, anything that adds or removes html elements are structural directives Attribute directives changes the look and feel of elements - like ngStyle

95
Q

How would you pass data from a parent to a child component or a child to a parent component

A

child to parent component

  1. In the parent component, create a callback function. …
  2. Pass the callback function to the child as a props from the parent component.
  3. The child component calls the parent callback function using props and passes the data to the parent component.

parent to child component

the parent component passes props to the child component and the child can then access the data from the parent via this.props.

96
Q

What is startup.cs, Is it possible to run an ASP.NET Core API without one?

A

startup.cs registers services and injection of modules in HTTP pipeline. Startup. cs file contains Startup class which triggers at first when application launches and even in each HTTP request/response. No you can’t run without it.

97
Q

What are the different types of dependency lifetimes in ASP.NET?

A

Transient — Services are created each time they are requested
Scoped — Services are created on each request (once per request)
Singleton — Services are created once for the lifetime of the application.

98
Q

In what situation would you use each dependency lifetime?

A

use transient for adding items to cart
use scoped for purchasing
singleton for creating account

99
Q

Rest vs Soap?

A

REST:
HTTP

Any format, JSON is easier to parse and is lightweight
Stateless
Good caching support
Just https, not truly end to end security
Simpler, easy to get up and running because http is everywhere and you don’t have to deal with XML
Contract based on HTTP standards & conventions & is either hypermedia or an API description language
Errors: 4xx, 5xx, status codes
Gets told by the client what it wants to do to a resource via http verb

SOAP:
Any protocol over HTTP, just uses POST
XML
Could be stateful
Supports caching but not at the http level
Lots of security support
Contract based on WSDL document
Errors: faults
Gets told by the client what it wants to do to a resource via articulating it in the soap message
100
Q

XML vs JSON?

A

Both JSON and XML are “self describing” (human readable)
Both JSON and XML are hierarchical (values within values)
Both JSON and XML can be parsed and used by lots of programming languages
Both JSON and XML can be fetched with an XMLHttpRequest

JSON doesn’t use end tag
JSON is shorter
JSON is quicker to read and write
JSON can use arrays

XML is much more difficult to parse than JSON.
JSON is parsed into a ready-to-use JavaScript object.

101
Q

Why use Soap over REST?

A

if you need more robust security, SOAP’s support for WS-Security can come in handy. It offers some additional assurances for data privacy and integrity. It also provides support for identity verification through intermediaries rather than just point-to-point, as provided by SSL (which is supported by both SOAP and REST).

Another advantage of SOAP is that it offers built-in retry logic to compensate for failed communications.

102
Q

What is the file that represents the database?

A

DBContext

103
Q

What class represents a collection of entities?

A

Entity Class

104
Q

Can you have multiple DBContexts?

A

yes

105
Q

What is a microservice?

A

A microservice architecture – a variant of the service-oriented architecture structural style – arranges an application as a collection of loosely-coupled services.

106
Q

How to toggle from one controller to another in a standalone app without any server side response.

A

using keyword

107
Q

what is flexbox in css?

A

The flex layout allows responsive elements within a container to be automatically arranged depending upon screen size.

108
Q

what is the box model?

A

refers to how HTML elements are modeled in browser engines and how the dimensions of those HTML elements are derived from CSS properties.

109
Q

what is local storage?

A

the process of storing digital data on physical storage devices, such as hard disc drives (HDDs), solid state drives (SSDs), or external storage devices, such as thumb drives or discs.

110
Q

what is session storage?

A

It enables developers to save and retrieve different values. Unlike local storage, session storage only keeps data for a particular session. The data is cleared once the user closes the browser window.

111
Q

what is normalization

A

a database design technique that reduces data redundancy and eliminates undesirable characteristics

112
Q

what are attributes in C#

A

Attributes are like adjectives, which are used for metadata annotation that can be applied to a given type, assembly, module, method and so on.