Friday, November 16, 2012



Interview Questions for Software Engineer Job


What is polymorphism?
It is the important concept of OOP, from the greek concept 'poly' means many 'morphism' means form, from this the definition  is "the ability to take more than one form"

EXAMPLE:
method overloading (static polymorphism...early binding)
method overriding (dynamic polymorphism...late binding)


Method overriding different from method overloading?


Overriding involves the creation of two or more methods with the same name and same signature in different classes (one of them should be parent class and other should be child).

Overloading is a concept of using a method at different places with same name and different signatures within the same class.
Abstraction

Refers to the process of exposing only the relevant and essential data to the users without showing unnecessary information.  Abstraction is the process to hide the complexity. Abstraction means to show only the necessary details to the client of the object. Do you know the inner details of the Monitor of your PC? What happen when you switch ON Monitor? Does this matter to you what is happening inside the Monitor?
Explain the concept of constructor?

Constructor is a special method of a class, which is called automatically when the instance of a class is created. It is created with the same name as the class and initializes all class members, whenever you access the class. The main features of a constructor are as follows:
Constructors do not have any return type
Constructors are always public
It is not mandatory to declare a constructor; it is invoked automatically by .NET Framework.


Namespace in .NET
Namespace is considered as a container that contains functionally related group of classes and other types.

Explain different types of inheritance.

Single inheritance - Contains one base class and one derived class
Hierarchical inheritance - Contains one base class and multiple derived classes of the same base class
Multilevel inheritance - Contains a class derived from a derived class
Multiple inheritance - Contains several base classes and a derived class

What is the difference between procedural and object-oriented programming?

Procedural programming is based upon the modular approach in which the larger programs are broken into procedures. Each procedure is a set of instructions that are executed one after another. On the other hand, OOP is based upon objects. An object consists of various elements, such as methods and variables.

Access modifiers are not used in procedural programming, which implies that the entire data can be accessed freely anywhere in the program. In OOP, you can specify the scope of a particular data by using access modifiers - public, private, internal, protected, and protected internal.

Execute Scalar is a Single value single column.

Execute Reader is a Read only forward only.

Execute Non Query is used for Insert, Update, and Delete Statements.


What is the difference between shadowing and overriding

Shadowing - Protecting against a subsequent base class modification that introduces a member you have already defined in your derived class
Overriding - Achieving polymorphism by defining a different implementation of a procedure or property with the same calling sequence

Delegates
A delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method. The delegate method can be used like any other method, with parameters and a return value.

Interfaces in C#
An interface in C# is simply a template for a class. Its part of how C# implements polymorphism.  An interface doesn’t contain any code, only definitions of methods, properties, events and indexers. A class that implements an interface will need to define the code used for these items. Here’s a short code snippet of an example C# interface.

public interface IMyItem
{
    int Id { get; set; }

    string Description { get; set; }

    string RunTest(int testNumber);

    event EventHandler TestStatus;

    string this[int index] { get; set;}
}

In this example, the interface includes two properties, a method, an event and an indexer. A class that used this interface would need to provide code for these items. While the code doesn’t have to do anything, it does have to be implemented by the class using the interface.
One powerful thing that you can do with interfaces is that you can have a class that implements more than one interface. One of my favorite usages is to not only implement a program specific interface but to also implement a generic List or Queue.

Abstract Classes in C#
An abstract class in C# is a class that can’t be instantiated and, like an interface, is intended to provide a common class definition that is shared by derived classes. Like an interface, the routines in an abstract class may be methods, properties, indexers and events. Unlike an interface, an abstract class may contain code although it may also have abstract methods that do not have code. Also, an abstract class may define constructors and destructors while an interface does not as well as internal private and protected variables

What is the difference between UserControl, WebControl?

UserControl: A custom control, ending in .ascx, that is composed of other web controls. Its almost like a small version of an aspx webpage. It consists of a UI (the ascx) and codebehind. Cannot be reused in other projects by referencing a DLL.
WebControl: A control hosted on a webpage or in a UserControl. It consists of one or more classes, working in tandem, and is hosted on an aspx page or in a UserControl. WebControls don't have a UI "page" and must render their content directly. They can be reused in other applications by referencing their DLLs.

base keyword
The base keyword is used to access members of the base class from within a derived class:
Call a method on the base class that has been overridden by another method.
Specify which base-class constructor should be called when creating instances of the derived class.

Authentication types in web.config?
URL: http://msdn.microsoft.com/en-us/library/aa291347(v=vs.71).aspx
ASP.NET implements additional authentication schemes using authentication providers, which are separate from and apply only after the IIS authentication schemes. ASP.NET supports the following authentication providers:
Windows (default)
Forms
Passport
None
To enable an authentication provider for an ASP.NET application, use the authentication element in either machine.config or Web.config as follows:

   mode=[Windows|Forms|Passport|None]
   
Each ASP.NET authentication provider supports an OnAuthenticate event that occurs during the authentication process, which you can use to implement a custom authorization scheme. The primary purpose of this event is to attach a custom object that implements the IPrincipal Interface to the context.

IsPOSTback function in Asp.Net?

URL: Is Postback is normally used on page _load event to detect if the page is getting generated due to postback requested by a control on the page or if the page is getting loaded for the first time. IsPostBack is a Boolean property of a page when is set (=true) when a page is first loaded. Thus, the first time that the page loads the IsPostBack flag is false and for subsequent PostBacks, it is true. Each time a PostBack occurs, the entire page including the Page_Load is ‘posted back‘and executed.

ASP.NET: Difference between Server.Transfer and response.Redirect?
In response.redirect the browser url changes to targeted page as well as in server.transfer the url remains same!
Response.Redirect should be used when:
·         we want to redirect the request to some plain HTML pages on our server or to some other web server
·         we don't care about causing additional roundtrips to the server on each request
·         we do not need to preserve Query String and Form Variables from the original request
·         we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary)
Server.Transfer should be used when:
·         we want to transfer current page request to another .aspx page on the same server
·         we want to preserve server resources and avoid the unnecessary roundtrips to the server
·         we want to preserve Query String and Form Variables (optionally)
·         we don't need to show the real URL where we redirected the request in the users Web Browser
Round-trip – Response.Redirect() first sends request for new page to the browser, then browser sends that request to the web-server, and after that your page changes. But Server.Transfer() directly communicate with the server to change the page hence it saves an extra  round-trip (to the browser) in the whole process.

Difference between Web.Config file and Global.asax?

Web.Config file is used....

1. To specify the application settings

2. To specify the session mechanism available to use for that application.

3. To Specify the Connection strings.

4. To specify the authentication and authorization.

5. To specify the http handlers.

6. To Specify different providers.


Global.asax file is used to specify the session and application event handlers. Which is handling application level events and session level events.

Advantages and Disadvantages of Session

Advantages:

* It helps to maintain user states and data to all over the application.
* It can easily be implemented and we can store any kind of object.
* Stores every client data separately.
* Session is secure and transparent from user.

Disadvantages:

Performance overhead in case of large volume of user, because of session data stored in server memory.
Overhead involved in serializing and De-Serializing session Data. Because In case of StateServer and SQLServer session mode we need to serialize the object before store.

ADO.Net
Encapsulates our queries and commands to provide a uniform access to various database management systems. ADO.Net is a successor of ADO (ActiveX Data Object). The prime features of ADO.Net are its disconnected data access architecture and XML integration.
Access Data Object simply stood for "ADO". EXTENSION OF ADO.NET is Activex Data Object. Main use of capturing datasource for bridge between the application layer to the database layer. in other words interaction between application to database with proper connection string under configurations

What is indexing?
Indexing is a way of sorting a number of records on multiple fields. Creating an index on a field in a table creates another data structure which holds the field value, and pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.
TRIGGERS
A Trigger is a named database object which defines some action that the database should take when some databases related event occurs. Triggers are executed when you issues a data manipulation command like INSERT, DELETE, UPDATE on a table for which the trigger has been created. They are automatically executed and also transparent to the user. But for creating the trigger the user must have the CREATE TRIGGER privilege. In this section we will describe you about the syntax to create and drop the triggers and describe you some examples of how to use them.

CREATE TRIGGER
The general syntax of CREATE TRIGGER is :
 CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW trigger_statement

What are the differences between final, finally, finalize Methods?
final is a keyword. It’s constant. It can’t be changed from its initiated value.

finally() method used exception handling concept.finally() block will execute whether or not try block can be execute. It’s used to close a file.

finalize is used when an object is just before deleted, it can be used in garbage collection.
Accessing Arrays
We can access an array item by passing the item index in the array. The following code snippet creates an array of three items and displays those items on the console.
// Initialize a fixed array one item at a time
int[ ] staticIntArray = new int[3];
staticIntArray[0] = 1;
staticIntArray[1] = 3;
staticIntArray[2] = 5;

// Read array items one by one
Console.WriteLine(staticIntArray[0]);
Console.WriteLine(staticIntArray[1]);
Console.WriteLine(staticIntArray[2]);


Recursive Function
A recursive method calls itself. Recursive methods are used extensively in programming and in compilers. They help with complex problems. They solve problems and puzzles with brute force. They exhaust all possibilities.
Pass by value versus reference in C#
Functions in C# may have a sequence of parameters. There are 3 ways a parameter can be passed into a function:
Pass by value (default way – no prefix; assumes that the variable value is set before the function is called)
Pass by reference (prefix with keyword ref; assumes that the variable value is set before the function is called)
Pass by reference (prefix with keyword out; assumes that the variable value will be set by the calling function)

Following are some common differences between an SP & a UDF:
Stored Procedures:
- Can be used to read and modify data.
- To run an SP Execute or Exec is used, cannot be used with SELECT statement.
- Cannot JOIN a SP in a SELECT statement.
- Can use Table Variables as well as Temporary Tables inside an SP.
- Can create and use Dynamic SQL.
- Can use transactions inside (BEGIN TRANSACTION, COMMIT, ROLLBACK) an SP.
- Can use used with XML FOR clause.
- Can use a UDF inside a SP in SELECT statement.
- Cannot be used to create constraints while creating a table.
- Can execute all kinds of functions, be it deterministic or non-deterministic.
Functions:
- Can only read data, cannot modify the database.
- Can only be used with SELECT statement, JOINS & APPLY (CROSS & OUTER).
- Can JOIN a UDF in a SELECT statement.
- Cannot use a Temporary Table, only Table Variables can be used.
- Cannot use a Dynamic SQL inside a UDF.
- Cannot use transactions inside a UDF.
- Cannot be used with XML FOR clause.
- Cannot execute an SP inside a UDF.
- Can be used to create Constraints while creating a table.
- Cannot execute some non-deterministic built-in functions, like GETDATE().
IS-A RELATIONSHIP, HAS-A RELATIONSHIP

Link: http://www.desy.de/gna/html/cc/Tutorial/node6.htm

Association is a relationship where all object have their own lifecycle and there is no owner. Let’s take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently.

Aggregation is a specialize form of Association where all object have their own lifecycle but there is ownership and child object cannot belongs to another parent object. Let’s take an example of Department and teacher. A single teacher cannot belong to multiple departments, but if we delete the department teacher object will not destroy. We can think about “has-a” relationship.

Composition is again specialize form of Aggregation and we can call this as a “death” relationship. It is a strong type of Aggregation. Child object does not have their lifecycle and if parent object deletes all child objects will also be deleted. Let’s take again an example of relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room cannot belongs to two different house if we delete the house room will automatically delete. Let’s take another example relationship between Questions and options. Single questions can have multiple options and option can not belong to multiple questions. If we delete questions options will automatically delete

Garbage Collection in .NET

The .NET Framework's garbage collector manages the allocation and release of memory for your application. Each time you create a new object, the common language runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects.

Run time Master page generate?

Hi, it is possible to change Theme and Masterpage dynamically.
But they have to be done on Page_Preinit Event like this
page.masterpagefile ="~/SecondMaster.master"
page.Theme = "SecondDefaultTheme"
What is Virtual Method in .Net?

By declaring base class function as virtual, we allow the function to be overridden in any of derived class. The virtual keyword is used while defining a class to specify that the methods and the properties of that class can be overridden in derived classes.

Cursor in Sql
A cursor is a set of rows together with a pointer that identifies a current row. In other word, Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis


There are two types of cursors in PL/SQL:
Implicit cursors:
These are created by default when DML statements like, INSERT, UPDATE, and DELETE statements are executed. They are also created when a SELECT statement that returns just one row is executed.
Explicit cursors:
They must be created when you are executing a SELECT statement that returns more than one row. Even though the cursor stores multiple records, only one record can be processed at a time, which is called as current row. When you fetch a row the current row position moves to next row.
What is Query String?

Query strings are usually used to send information from one page to another page like aspx?id=10.Most browsers impose a limit of 255 characters on URL length.

Very simple to pass the values from one page to another but these values are clearly visible in the browser.

we can access the Query String value as
string id;
id=Request.Params["id"];
Explian about the view state?

View State is a built in feature in web controls to persist data between page post backs.By default,Each control's of EnableViewState property will be set to true.so that we can disable the viewstate for the controls which we don't want to maintain state.
We can also disable View State for the entire page by adding EnableViewState=false to @page directive.View state data is encoded as binary Base64 - encoded which adds overhead to the page.This will be the disadvantage of the viewstate.


We can also store specfic data across the postbacks.

Example:
// Add item to ViewState
ViewState["state"]  = someValue;
//Reading items from ViewState
Response.Write(ViewState["state"]);
Control state in ASP.NET?
The control state allows us to save a control’s state information when the EnableViewState property is turned off. Unlike ViewState a developer can’t turn off control state. The control state can be implemented only in controls that you implement (should be used for custom controls).
Common Language Runtime (CLR)

As part of Microsoft's .NET Framework, the Common Language Runtime (CLR) is programming that manages the execution of programs written in any of several supported languages, allowing them to share common object-oriented classes written in any of the languages. The Common Language Runtime is somewhat comparable to the Java Virtual Machine .

HttpHandler in ASP.NET

In the simplest terms, an ASP.NET HttpHandler is a class that implements theSystem.Web.IHttpHandler interface.
ASP.NET HTTPHandlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler.
ASP.NET offers a few default HTTP handlers:
Page Handler (.aspx): handles Web pages
User Control Handler (.ascx): handles Web user control pages
Web Service Handler (.asmx): handles Web service pages
Trace Handler (trace.axd): handles trace functionality

Global Assembly Cache (GAC)

Common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer. The Global Assembly Cache Tool (Gacutil.exe) that allows you to view and manipulate the contents of the Global Assembly Cache.

Abstract Class vs Interface
Abstract class can contain abstract methods, abstract property as well as other members (just like normal class).
Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract.

         //Abstarct Class
public abstract class Vehicles
      {
        private int noOfWheel;
        private string color;
        public abstract string Engine
        {
            get;
            set;
        }
        public abstract void Accelerator();
      }

      //Interface
public interface Vehicles
      {
        string Engine
        {
            get;
            set;
        }
        void Accelerator();
      }

How can we take decision about when we have to use Interface and when Abstract Class.
Basically abstract class is an abstract view of any real word entity and interface is more abstract one. When we thinking about the entity there are two things one is intention and one is implementation. Intention means I know about the entity and also may have idea about its state as well as behavior but don’t know about how its looks or works or may know partially. Implementation means actual state and behavior of entity.

Interface:
Every single Method declared in an Interface will have to be implemented in the subclass. Only Events, Delegates, Properties (C#) and Methods can exist in an Interface. A class can implement multiple Interfaces.
Abstract Class:
Only Abstract methods have to be implemented by the subclass. An Abstract class can have normal methods with implementations. Abstract class can also have class variables beside Events, Delegates, Properties and Methods. A class can only implement one abstract class only due non-existence of Multi-inheritance in C#.

Early Binding

The name itself describes that compiler knows about what kind of object it is, what are all the methods and properties it contains. As soon as you declared the object, .NET Intellisense will populate its methods and properties on click of the dot button.

Common Examples:
ComboBox cboItems;

ListBox lstItems;
In the above examples, if we type the cboItem and place a dot followed by, it will automatically populate all the methods, events and properties of a combo box, because compiler already know it's an combobox.

Late Binding

The name itself describes that compiler does not know what kind of object it is, what are all the methods and properties it contains. You have to declare it as an object, later you need get the type of the object, methods that are stored in it. Everything will be known at the run time.

Common Examples:
·         Object objItems;

·         objItems = CreateObject("DLL or Assembly name");



C# boxing and unboxing
C# Type System contains three Types, they are Value Types, Reference Types and Pointer Types. C# allows us to convert a Value Type to a Reference Type, and back again to Value Types . The operation of Converting a Value Type to a Reference Type is called Boxing and the reverse operation is called Unboxing.

Boxing
  1:    int Val = 1;
  2:    Object Obj = Val; //Boxing
The first line we created a Value Type Val and assigned a value to Val. The second line , we created an instance of Object Obj and assign the value of Val to Obj. From the above operation (Object Obj = i ) we saw converting a value of a Value Type into a value of a corresponding Reference Type . These types of operation are called Boxing.
UnBoxing

  1:    int Val = 1;
  2:    Object Obj = Val; //Boxing
  3:    int i = (int)Obj; //Unboxing

.NET Framework 4 Specifications
·         ControlRenderingCompatabilityVersion Setting in the Web.config File
·         ClientIDMode Changes
·         HtmlEncode and UrlEncode Now Encode Single Quotation Marks
·         ASP.NET Page (.aspx) Parser is Stricter
·         Browser Definition Files Updated
·         System.Web.Mobile.dll Removed from Root Web Configuration File
·         ASP.NET Request Validation
·         Default Hashing Algorithm Is Now HMACSHA256
·         Configuration Errors Related to New ASP.NET 4 Root Configuration
·         ASP.NET 4 Child Applications Fail to Start When Under ASP.NET 2.0 or ASP.NET 3.5 Applications
·         ASP.NET 4 Web Sites Fail to Start on Computers Where SharePoint Is Installed
·         The HttpRequest.FilePath Property No Longer Includes PathInfo Values
·         ASP.NET 2.0 Applications Might Generate HttpException Errors that Reference eurl.axd
·         Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode Changes to the ASP.NET Code Access Security (CAS) Implementation
·         MembershipUser and Other Types in the System.Web.Security Namespace Have Been Moved
·         Output Caching Changes to Vary * HTTP Header
·         System.Web.Security Types for Passport are Obsolete
·         The MenuItem.PopOutImageUrl Property Fails to Render an Image in ASP.NET 4
·         Menu.StaticPopOutImageUrl and Menu.DynamicPopOutImageUrl Fail to Render Images When Paths Contain Backslashes

Enum: Enums store special values. They make programs simpler. If you place constants directly where used, your C# program becomes complex. It becomes hard to change. Enums instead keep these magic constants in a distinct type. They improve code clarity. http://www.dotnetperls.com/enum

SQL INNER JOIN KEYWORD

The INNER JOIN keyword returns rows when there is at least one match in both tables.
SQL INNER JOIN Syntax
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
SQL LEFT JOIN KEYWORD

The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2).
SQL LEFT JOIN Syntax
SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
SQL RIGHT JOIN KEYWORD

The RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1).
SQL RIGHT JOIN Syntax
SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
SQL FULL JOIN KEYWORD

The FULL JOIN keyword return rows when there is a match in one of the tables.
SQL FULL JOIN Syntax
SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
SQL AGGREGATE FUNCTIONS

SQL aggregate functions return a single value, calculated from values in a column.
Useful aggregate functions:
AVG() - Returns the average value
COUNT() - Returns the number of rows
FIRST() - Returns the first value
LAST() - Returns the last value
MAX() - Returns the largest value
MIN() - Returns the smallest value
SUM() - Returns the sum
Some relevant questions....

Difference b/w View and Control states?
How to get largest number from a comma separated string using function, using Asp.Net?
How to get Uppercase Letter in Comma separated array?
What is MVC, and how to implement Action Result in MVC?
How to get 2nd largest record from table field (Query)?
Passing through reference and passing through object?

How to Build interactive Design in Power Pages

 Need to Create a design in figma/or any UX tool Create a Power pages site. Create new Page Open page in VS Code in every page there are the...