Infosys Flashcards
Difference between REST and SOAP
REST is Synchronous uses XML, Json, Plain Text, etc., transfer over HTTP, Javascript support is easy, calls services using HTTP request, uses XML AND JSON to send and receive data. Business logic is URIs Also, no error handling. Example of REST documentation is Swagger. Emphasizes stateless communication
SOAP is Asynchronous, uses only XML well documented but has many options with respect to documentation that can be difficult to understand, error handling is built in, transfers over HTTP, SMTP, FTP etc., its business logic is services interfaces. Supports stateless and stateful operations
Default class & default member
class= internal
member=private
What is REST?
Rest stands for Representational State Transfer. It tells you how you should transfer information and communicate with the client. An architectural style that uses Service Oriented Architecture; Restful service pertains to creating a web service. It is compatible with http(s) protocols & can use any messaging format such as .json, xml or a custom format. Its lightweight and consumes less bandwidth
What is AJAX and have you used it in a project before?
Asynchronous JS and XML
Used to grab information only with XML type backend server hence the name
But now updated for the object to also include JSON to be relevant
**This is how we send request and fetch API
What is routing?
[Route(“[controller]”)]
the middleman between the asp.net and the client and handles the http responses and routes the information back to the client
Helps ASP.Net to route the user’s http request for example which controller and which action inside of the controller routing where the http request should go to.
The routing middleware is used to find the appropriate controller and action in the controller to handle the request
Http Life Cycle
Your browser (the client) will send a request (the url you sent)
The server will receive that request & do some processes
Server will send a response (html, css, json, js etc)
Client will receive response for browser to process the response
What is the HTTP response codes?
1xx Informational 2xx Successful status 3xx Redirection 4xx Client errors 5xx Server errors
Http methods (what they do)
GET: request data,
POST: sends data to server (HTML)
PUT: creates a new resource or replaces
DELETE: delete request
What are abstract methods?
~implicitly a virtual method.
~declarations are only permitted in abstract classes
~abstract method declaration provides no actual implementation,
~there is no method body, the method declaration
~ simply ends with a semicolon and there are NO curly braces { } following the signature.
What is Interface?
Complier enforces contracts, & all methods are public abstract, variables are public, static, or final (declaring behaviors for objects) An interface describes what behaviors (verb) A class should have; it provides none of its own
What is a constructor?
is used to initialize the state of an object.
not required to have a return type.
is invoked implicitly.
The compiler provides a default constructor if you don’t have any constructor in a class.
The constructor’s name must be same as the class name.
5 types: Default, Copy, Parameterized, Copy, Static, Private
Give the syntax for attribute routing
The general syntax is {parameter:constraint}
Ex:
[Route(“customers/{customerId}/orders/{orderId}”)]
public Order GetOrderByCustomer(int customerId, int orderId) { … }
Connection differences between ADO.NET and Entity Framework
ADO.Net is directly connected to the data source and gives better performance, entity framework translates the LINQ queries to SQL first and then process the query
How do you connect API to the database?
Through a connection string in our azure server
What is authentication and authorization
Authentication is checking the identity and authorization is the permission levels of access
What are SOLID principles?
Enables us to manage most of the software design problems, intended to make software designs more understandable Single Responsibility: Open Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle
SOLID concepts
A class should have only one reason to change, and the responsibility should be encapsulated by the class Open for extension closed for modification means to allow new functionality with minimal changes to existing code Objects are replaceable with instances of subtypes without altering the correctness of the program Separate multiple interfaces are better than one shouldn’t enforce clients to implement interfaces they don’t use Higher level modules shouldn’t depend on low level modules
OOP Pillars
Encapsulation - Wrapping up of the data & data hiding, with use of access modifiers to provide levels of access
Abstraction - Showing only essential features of the program instead on un-necessary details.
Inheritance - Is a way to extend a type so that its properties and behaviors can be extended/branched further.
Polymorphism- Ability to implement inherited properties or methods in different ways across multiple abstractions.
Static/Compile time polymorphism or Dynamic/Runtime polymorphism.
OOP Advantages
~OOPs makes development and maintenance easier whereas in a procedure-oriented programming language it is not easy to manage if code grows as project size increases.
~OOPs provides data hiding whereas in a procedure-oriented programming language a global data can be accessed from anywhere.
What is a constructor?
5 types: Default, Copy, Parameterized, Copy, Static, Private
is used to initialize the state of an object.
not required to have a return type.
is invoked implicitly.
The Java compiler provides a default constructor if you don’t have any constructor in a class.
The constructor’s name must be same as the class name.
What is Interface?
Complier enforces contracts, & all methods are public abstract, variables are public, static, or final (declaring behaviors for objects) An interface describes what behaviors (verb) A class should have; it provides none of its own
What are abstract methods?
~implicitly a virtual method.
~declarations are only permitted in abstract classes
~abstract method declaration provides no actual implementation,
~there is no method body, the method declaration
~ simply ends with a semicolon and there are NO curly braces { } following the signature.
Http methods (what they do)
GET: request data,
POST: sends data to server (HTML)
PUT: creates a new resource or replaces
DELETE: delete request
Give the syntax for attribute routing
The general syntax is {parameter:constraint}
Ex:
[Route(“customers/{customerId}/orders/{orderId}”)]
public Order GetOrderByCustomer(int customerId, int orderId) { … }
What is method overloading and overriding?
~Method overriding is an example of runtime polymorphism, ~Redefining the method of the parent class into the child class. ~To override the method in the parent class, in child class you need to specify a method of the same signature ~necessary to make a method overridable by using abstract or virtual keyword in base class ~In child class use the keyword override to override these methods.
What is method overloading and overriding?
Overloading
~Method overloading is an example of static/compile time polymorphism
~Creation of methods with the same name as another in the same class, nut differs in parameters (order number, type)
~Methods with the same name behaves differently based on signatures(parameters):
What is singleton
A single constructor is private and parameter less. This prevents other classes from instantiating it
What is a sealed class in C#?
The sealed modifier prevents other classes from inheriting from it.
What is test driven development?
software development process used to test cases before software is fully developed and track software development by repeatedly testing the software against all test cases.
- Mantra: Red, Green, Refactor - Structure: Arrange, Act, Assert
How would you write a unit test?
[ Test ]
Triple A’
Arrange: initializes object and set values of data passed to the method
Act: invokes the method, testing the arranged parameters
Assert: verifies the action does what it’s supposed to do
What is JSON?
Javascript object notation is a readable language for users in a data-interchange
Code Coverage
It is the percentage given to you on how much lines of your code are covered by unit testing
Static
A non-access modifier determines if the method or variable belongs to a class as a whole or as an instance. Methods and variables labeled static without the need to create an object of the class, but the main method is always labeled A static method can not be overridden because it pertains to the class not the object, and the static method can be called without the class instance
Do you have any experience with LINQ to ADO.Net
It is a query language that is very similar to our SQL
useful for filtering/acquiring/aggregating data
Method syntax- use methods to perform the queries (simple queries)
Query syntax- more like SQL in that you create a statement-like operation using keywords (joins)
Agile:
Give the client what they want with little to no documentation, an Asynchronous, automatic development/ deployment cycle
How would you use a connection string without hard coding it into your program?
Some type of secret key or a configuration manager System.Configuration
How to achieve multiple inheritance in c#
Multiple inheritance in C#( not allowed)
Model Binding
It is a way to bind data (JSON objects) coming from HTTP request to be automatically mapped into a C# model
Model Binder looks for those values in different ways:
o QueryString -> Primitive types
o Request Body -> Complex Types
Just like HTTP transfers information by JSON files. ASP.NET automatically maps the JSON object into a C# object and vise-versa
.NET & C#
What is MVC. (Model View Controller)
used to implement user interfaces, data, and controlling logic.
Used to decouple where to or more systems work/connect without direct connectivity, uses a buffer to separate the fetch and decode stages from the execution stage
What is Entity Framework
An open source ORM, object relational mapping for .NET
defines context classes and entity classes that make up a model and uses migrations to create a database
ADO.NET and ASP.NET
ASP.NET is the compiled language. ASP uses ADO (ActiveX Data Objects) technology to connect and work with databases. ASP.NET uses ADO.NET to connect and work with databases. ASP is partially object-oriented.
ADO.NET uses Microsofft.Data.Sqlclient
What is a DLL?
Dynamic link library contains code and data that can be used by more than one program at the same time
What is Truncate and Delete commands in SQL?
Are Data Definition Languages Truncate command (Keeps table removes records from table) removes all rows/records from a table, without logging individual row deletions,
Delete: deletes the whole table unless specified
What do you know about normalization?
Organizing data in database reducing redundancy, improve referential integrity to read/write with consistency remove insertion, update, and deletion anomalies.
1NF~ columns should be atomic, no multiple values, separated by a comma.
Table doesn’t contain repeating column groups
Identify each record uniquely using primary key
2NF~all conditions of 1NF, move redundant data to separate table
Create relationship between these tables using foreign keys
3NF-meets all conditions of 1NF & 2NF
Does not contain columns(attributes) that are not fully dependent upon the primary