Thursday, 30 December 2021

IQ

1. What is C#?

C# is an object-oriented, type-safe programming language developed by Microsoft, used mainly for building Windows, Web, and enterprise applications on the .NET platform.

2. Types of Comments in C#

 Single-line → `// comment`
 Multi-line → `/ comment /`
 XML Documentation → `/// comment`

3. Object in C#
An object is an instance of a class that occupies memory and represents real-world entities with state (fields) and behavior (methods).



4. What is the .NET Framework?

A software development platform by Microsoft that provides a runtime (CLR) and a class library for building and running applications.


5. Components of .NET

 CLR (Common Language Runtime)
 BCL (Base Class Library)
 ASP.NET
 ADO.NET
 WPF/WCF
 Languages (C#, VB.NET, F#)

6. What is OOP?

OOP (Object-Oriented Programming) is a paradigm based on Encapsulation, Inheritance, Polymorphism, and Abstraction.



7. Array vs ArrayList

 Array: Fixed size, stores same type, faster.
 ArrayList: Dynamic size, stores objects of different types, slower due to boxing/unboxing.



8. Control Statements in C#

 Conditional: `if`, `switch`
 Looping: `for`, `while`, `foreach`, `do-while`
 Jump: `break`, `continue`, `goto`, `return`



9. Classes in C#

A class is a blueprint for creating objects, containing fields, methods, properties, constructors, etc.



10. Abstract Class vs Interface in .NET

 Abstract class: Can have implementation + abstract members, supports inheritance.
 Interface: Only contracts (no implementation until C# 8 default methods). Supports multiple inheritance.



11. Constructors in C#

Special methods used to initialize objects. Types: Default, Parameterized, Copy, Static, Private constructors.



12. Assembly

A compiled code library in .NET (.dll or .exe) that contains metadata and IL code.



13. Private vs Public Assembly

 Private: Used by a single application (stored in app folder).
 Public (Shared): Used by multiple applications, stored in GAC.



14. MVC (Model-View-Controller)

 Model: Business/data logic.
 View: UI layer.
 Controller: Handles user input and communicates between model & view.



15. Languages supported by .NET

C#, VB.NET, F#, C++/CLI, IronPython, IronRuby, etc.



16. ViewBag vs ViewData

 ViewData: Dictionary, weakly typed, requires type casting.
 ViewBag: Dynamic property, easier to use, wrapper around ViewData.



17. Action Filters in ASP.NET MVC

Attributes that run before/after an action (e.g., `OnActionExecuting`). Used for logging, authorization, caching.



18. Authorize Filter vs Action Filter

 Authorize Filter: Specifically checks authentication/authorization.
 Action Filter: Can perform any pre/post logic (e.g., logging, validation).



19. Extension Methods

Static methods that add new functionality to existing types without modifying their source code.



20. async/await

Keywords used for asynchronous programming in C# to avoid blocking threads.



21. SOLID Principles

 S: Single Responsibility
 O: Open/Closed
 L: Liskov Substitution
 I: Interface Segregation
 D: Dependency Inversion



22. Dependency Injection

Design pattern where dependencies are injected at runtime instead of being created inside the class.



23. Singleton Design Pattern

Ensures a class has only one instance globally with a global point of access.



24. Delegates (Func, Predicate, Action)

 Func<T>: Returns a value.
 Action<T>: No return.
 Predicate<T>: Returns boolean.



25. Sealed Class

A class that cannot be inherited. Used for security and performance.



26. Caching Techniques

 In-memory cache
 Distributed cache (Redis)
 Output caching (ASP.NET MVC)



27. Using Statement in C#

Used for automatic disposal of resources (implements IDisposable).



28. GC.Collect vs Finalize vs Dispose

 GC.Collect(): Forces garbage collection.
 Finalize(): Called by GC before object destruction.
 Dispose(): Manually releases resources.



29. Token Generation Techniques

 Random values (UUID)
 JWT (HMAC/RSA)
 OAuth2 Tokens
 Time-based (OTP)



30. Code First vs DB First

 DB First: Model generated from DB (faster for existing DBs).
 Code First: Classes first, then DB (better for agile development).



31. Bundle Config & CDN

 Bundle Config: Combines/minifies CSS & JS for performance.
 CDN: Loads static files from distributed network servers.



32. Application Object vs Session Object

 Application: Shared across all users.
 Session: Specific to a single user.



33. IIS Request Processing

Request → HTTP.sys → IIS → ASP.NET pipeline → Handler → Response.



34. ref vs out

 ref: Must be initialized before passing.
 out: Must be assigned inside the method.



35. HTTP Status Codes

 200: OK
 403: Forbidden
 500: Internal Server Error



36. What is Render in ASP.NET?

Method that generates HTML from server controls and sends to client browser.



37. Web API Testing Techniques

 Postman, Swagger, Fiddler, NUnit, MSTest.



38. Web API vs WCF

 Web API: RESTful, JSON/XML, lightweight.
 WCF: SOAP, supports multiple protocols (TCP, HTTP).



39. Handle Exceptions without try-catch

 Global.asax Application\_Error
 Exception filters
 Middleware in ASP.NET Core



40. HTTP Verbs in Web API

 GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.



41. Contracts in WCF

Defines the service.

 Service Contract: Defines operations.
 Message Contract: Defines SOAP message structure.



42. Install Certificates in IIS

IIS Manager → Server Certificates → Import/Install → Bind to site.



43. Passport Authentication

Single sign-on service by Microsoft for authenticating users across multiple sites.



44. Web Service vs WCF

 Web Service: Only HTTP & SOAP.
 WCF: Multiple protocols (TCP, MSMQ, HTTP).



45. Web API Token Types

 JWT
 Bearer
 OAuth2 Access/Refresh Tokens



46. Where Configure Endpoints in WCF

Configured in Web.config/App.config under `<system.serviceModel>`.



47. XML vs JSON

 XML: Verbose, supports attributes/namespaces.
 JSON: Lightweight, faster, used in REST APIs.



48. Authentication & Authorization in Web API

 Authentication: Validates identity (who you are).
 Authorization: Validates permissions (what you can do).



49. CSRF Protection in Web API

 Anti-forgery tokens
 SameSite cookies
 Double-submit cookie technique



50. CORS in Web API

Enable with `[EnableCors]` attribute or middleware to allow cross-origin requests.



51. Authentication Filters in Web API

Custom filters to authenticate requests before hitting controllers.



52. Basic Authentication in Web API

Uses `Authorization: Basic <base64(username:password)>` header.



53. Forms Authentication

Uses cookies to store authenticated session ID.



54. Windows Authentication

Uses AD/NTLM/Kerberos credentials for intranet apps.



55. SSL in Web API

Configured via IIS bindings or `RequireHttpsAttribute` in MVC/Web API.

Saturday, 20 November 2021

React JS IQ

React JS:
Remove duplicate characters in array of elements
var sandwiches = ['turkey', 'ham', 'turkey', 'tuna', 'pb&j', 'ham', 'turkey', 'tuna'];
var deduped = Array.from(new Set(sandwiches));

// Logs ["turkey", "ham", "tuna", "pb&j"]
console.log(deduped);


  • given word last letter should be capital.
  • Cloure function
          Closures are inner functions that have access to the outer function’s variables and parameters. Even after the outer function’s execution is finished, the inner functions have access to the variables in the outer function. Closures are everywhere in JavaScript and you’ve probably been using it even if you have not realised it yet.

  • diff class component, functional component
Functional Components                                           Class Components                
A functional component is just a plain JavaScript function that accepts props as an argument and returns a React element.A class component requires you to extend from React. Component and create a render function which returns a React element.
There is no render method used in functional components.It must have the render() method returning HTML
Also known as Stateless components as they simply accept data and display them in some form, that they are mainly responsible for rendering UI.Also known as Stateful components because they implement logic and state.
React lifecycle methods (for example, componentDidMount) cannot be used in functional components.React lifecycle methods can be used inside class components (for example, componentDidMount).
  • Error Handling in React.
  • how to give generic exception and display the message
  • error boundaris
  • what is call back hell function
  • what is non blocking io---asyncronous call
  • what is stright mode
  • Differenec Virtual dom and Real dom.
  • react life cycle
  • what is promise unchining,promise.all-- promise is asyncronous call
  • diff let,var,const
  • what is closur function,nested function
  • basic ES6 features- let and var,promise,iterator
  • How to deploy React application
  • React Router types how it works,nested routes
  • What is Arrow function,uses
  • spread operator
  • what is generator
  • what is hooks- use memo,use context,use effect
  • How redux works
  • diff element and component
  • how to prevent rerendering-- using pure componentd or use memo
  • React application performence.
  • synthatic events.
  • what is controlled components
  • how to set initial state in Redux
  • Store in Redux
  • How many types are Reducers

  • what is Data binding
  • What is context API

Sunday, 3 October 2021

React JS questions

  1. Remove duplicate characters in array of elements
  2. Given word last letter should be capital.
  3. Closure function
  4. diff class component, functional component
  5. Error Handling in React.
  6. how to give generic exception and display the message
  7. error boundaris
  8. what is call back hell function
  9. what is non blocking io---asyncronous call
  10. what is stright mode
  11. Differenec Virtual dom and Real dom.
  12. react life cycle
  13. what is promise unchining,promise.all-- promise is asyncronous call
  14. diff let,var,const
  15. what is closur function,nested function
  16. basic ES6 features- let and var,promise,iterator
  17. How to deploy React application
  18. React Router types how it works,nested routes
  19. What is Arrow function,uses
  20. spread operator
  21. what is generator
  22. what is hooks- use memo,use context,use effect
  23. How redux works
  24. diff element and component
  25. how to prevent rerendering-- using pure componentd or use memo
  26. React application performence.
  27. synthatic events.
  28. what is controlled components
  29. how to set initial state in Redux
  30. Store in Redux
  31. How many types are Reducers
  32. Redux life cycle
  33. Diff State and props
  34. what is Data binding
  35. What is context API

Javascript:
  1. diff betewen Null and undefined
  2. typeof(null)
  3. Event bubling
  4. Define Json array
  5. how to detect object like mobile or tab-- using responsiveness media query
  6. purpose of encoding url
  7. what is decorater
  8. copy an object in javascript-- object

  1. Remove duplicate characters in array of elements
    • const uniqueNames = Array.from(new Set(names));
  1. Given word last letter should be capital.
  • const cap = str => str
                         .split(' ')
                         .map(x => (
                             x.length === 1 ? 
                                 x.toUpperCase() : 
                                `${x[0].toUpperCase()}${x.slice(1,-1)}${x[x.length -1].toUpperCase()}`)
                         )  
                         .join(' ')
    
    console.log(cap("a quick brown fox"))
    1. diff class component, functional component
  • There is no render method used in functional components.

    React lifecycle methods (for example, componentDidMount) cannot be used in functional components.
    It must have the render() method returning HTML
    React lifecycle methods can be used inside class components (for example, componentDidMount).

Tuesday, 28 September 2021

IQ

  1. What tecnics are using for generating tokens
  2. Which one is faster DBfirst or code first
  3. what is bundle config and CDN
  4. what is application object and session object and differenece
  5. abstarct class and interface
  6. IIS request processing
  7. status codes-403,200,500
  8. what render
  9. web api testing tecnincs
  10. difference web api,wcf.
  11. without using try block how to handle exceptions
  12. verbs in web api
  13. what are contracts
  14. diffbetween service contract and message contract
  15. solid principles
  16. How to Install certificates in IIS
  17. Passport authentication works
  18. Difference between Webservice/WCF
  19. Webapi Token types
  20. Code first/DB first approach Which one better
  21. Where configure endpoints in WCF
  22. Differenec between XML/JSON
  23. Bundle config/CDN which one is better

Monday, 20 September 2021

IQ

  1. What is Base class for Asp.net
  2. Authentication and Authorization config settings
  3. Forms Authentication config settings
  4. Difference between Datareader/Dataset, Handlers/Modules
  5. How to make web api calls asynchronously.
  6.  How many ways to pass data to View to controller
  7. Merge key word in sql.
  8. CTE main purpose
  9. Solid principles
  10. What type of code in Pre render
  11. CI/CD process.
1) Given number is even or odd in c# without using condition

using System;
class test 
{
  static void Main() 
   {
    string[] arr = {"Even", "Odd"};
      
    Console.Write("Enter the number: ");
     
    string val;

    val = Console.ReadLine();

    int no = Convert.ToInt32(val);
 
    Console.WriteLine(arr[no%2]);
  }
}

2) How can Select Only last Row of the Table Using Sql

   SELECT TOP 1 * FROM MyTable ORDER BY MyColumn ASC

3) scaling in sql server

  Horizontal and vertical scaling

   The following figure shows the horizontal and vertical dimensions of scaling, which are the basic ways the elastic databases can be scaled.

  Horizontal scaling refers to adding or removing databases in order to adjust capacity or overall performance, also called "scaling out". 



Sharding, in which data is partitioned across a collection of identically structured databases, is a common way to implement horizontal scaling.
Vertical scaling refers to increasing or decreasing the compute size of an individual database, also known as "scaling up."

Most cloud-scale database applications use a combination of these two strategies. For example, a Software as a Service application may use horizontal scaling to provision new end-customers and vertical scaling to allow each end-customer's database to grow or shrink resources as needed by the workload.

Horizontal scaling is managed using the Elastic Database client library.

Vertical scaling is accomplished using Azure PowerShell cmdlets to change the service tier, or by placing databases in an elastic pool.

Cons of JavaScript

1. Client-side Security

Since the JavaScript code is viewable to the user, others may use it for malicious purposes. These practices may include using the source code without authentication. Also, it is very easy to place some code into the site that compromises the security of data over the website.

2. Browser Support

The browser interprets JavaScript differently in different browsers. Thus, the code must be run on various platforms before publishing. The older browsers don’t support some new functions and we need to check them as well.

3. Lack of Debugging Facility

Though some HTML editors support debugging, it is not as efficient as other editors like C/C++ editors. Also, as the browser doesn’t show any error, it is difficult for the developer to detect the problem.

4. Single Inheritance

JavaScript only supports single inheritance and not multiple inheritance. Some programs may require this object-oriented language characteristic.

5. Rendering Stopped

A single code error can stop the rendering of the entire JavaScript code on the website. To the user, it looks as if JavaScript was not present. However, the browsers are extremely tolerant of these errors.

Difference between inline query and stored procedure

1.Stored procedures are strored in a pre complied form.That is once a Stored procedure is executed, the compiled code is used in subsequent calls. This is not possible with inline queries.

2.Stored procedures reduces network traffic. 
Since Stored procedures are stored in the server, only the name of Stored procedure is required to pass to the server. But in the case of inline queries , the complete query has to be passed to the server. So inline queries will increase network traffic when the queries are very large.

3.Stored procedures support Deferred Name Resolution.That is we can create stored procedures for objects(eg:- tables) which are not yet created ( and will be creating in the near future)

4.Stored procedures prevents SQL Injection Errors.

5.By using Stored procedures we can seperate all the queries from the Business logic code.
Therefore we can create a seperate layer.
But while writing inline queries , all the queries have to be written (mixed up ) with the business logic code. This create problem while debugging.

6.Developers can work simultaneously while using stored procedures.
While a programmer writes business logic, another one can create stored procedures at the same time.

Friday, 19 March 2021

Monday, 15 March 2021

React JS QS

 

What is React?

React is an open-source frontend JavaScript library which is used for building user interfaces especially for single page applications. It is used for handling view layer for web and mobile apps. React was created by Jordan Walke, a software engineer working for Facebook. React was first deployed on Facebook's News Feed in 2011 and on Instagram in 2012.

What are the major features of React?

The major features of React are:

  • It uses VirtualDOM instead of RealDOM considering that RealDOM manipulations are expensive.
  • Supports server-side rendering.
  • Follows Unidirectional data flow or data binding.
  • Uses reusable/composable UI components to develop the view.

What is JSX?

JSX is a XML-like syntax extension to ECMAScript (the acronym stands for JavaScript XML). Basically it just provides syntactic sugar for the React.createElement() function, giving us expressiveness of JavaScript along with HTML like template syntax.

In the example below text inside <h1> tag is returned as JavaScript function to the render function.

class App extends React.Component {
  render() {
    return(
      <div>
        <h1>{'Welcome to React world!'}</h1>
      </div>
    )
  }
}

How to create components in React?

There are two possible ways to create a component.

  1. Function Components: This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as first parameter and return React elements:

    function Greeting({ message }) {
      return <h1>{`Hello, ${message}`}</h1>
    
    }
  2. Class Components: You can also use ES6 class to define a component. The above function component can be written as:

    class Greeting extends React.Component {
      render() {
        return <h1>{`Hello, ${this.props.message}`}</h1>
      }
    }

When to use a Class Component over a Function Component?

If the component needs state or lifecycle methods then use class component otherwise use function component.However, from React 16.8 with the addition of Hooks, you could use state , lifecycle methods and other features that were only available in class component right in your function component.


What is state in React?

State of a component is an object that holds some information that may change over the lifetime of the component. We should always try to make our state as simple as possible and minimize the number of stateful components.

Let's create an user component with message state,

class User extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      message: 'Welcome to React world'
    }
  }

  render() {
    return (
      <div>
        <h1>{this.state.message}</h1>
      </div>
    )
  }
}

state

State is similar to props, but it is private and fully controlled by the component. i.e, It is not accessible to any component other than the one that owns and sets it.