Thursday, October 11, 2012

Most Important Interview Questions(OOP, Asp.NET, PHP)



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.
With examples………
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.

Example of Virtual Method in .Net:

Class parent
{
virtual void hello()
{ Console.WriteLine(“Hello from Parent”); }
}

Class child : parent
{
override void hello()
{ Console.WriteLine(“Hello from Child”); }
}

static void main()
{
parent objParent = new child();
objParent.hello();
}

//Output
Hello from Child.

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)

Abstract class?
Virtual functions?
Diff b/w View and Control states?
Entity framework?
LINQ queries?
How to get largest number from 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?
All SQL joins?
Hypertext, Hyperlink?
Diff b/w Datatable and DataReader?
Diff b/w Div & Span?
How to get 2nd largest record from table field (Query)?
Passing through reference and passing through object?
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
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
What is Polymorphism in OOPS?
·         Polymorphism is one of the primary characteristics (concept) of object-oriented programming
·         Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details
·         Polymorphism is the characteristic of being able to assign a different meaning specifically, to allow an entity such as a variable, a function, or an object to have more than one form
·         Polymorphism is the ability to process objects differently depending on their data types
·         Polymorphism is the ability to redefine methods for derived classes.

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, as in this example:
C#
public delegate int PerformCalculation(int x, int y);

Any method that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate. This makes is possible to programmatically change method calls, and also plug new code into existing classes. As long as you know the delegate's signature, you can assign your own delegated method.
This ability to refer to a method as a parameter makes delegates ideal for defining callback methods. For example, a sort algorithm could be passed a reference to the method that compares two objects. Separating the comparison code allows the algorithm to be written in a more general way.


Delegates Overview
Delegates have the following properties:
·         Delegates are similar to C++ function pointers, but are type safe.
·         Delegates allow methods to be passed as parameters.
·         Delegates can be used to define callback methods.
·         Delegates can be chained together; for example, multiple methods can be called on a single event.
·         Methods don't need to match the delegate signature exactly. For more information, see Covariance and Contravariance

Interfaces in C#

An interface in C# is simply a template for a class. It’s 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.
Here’s a simple example of a C# abstract class…
public abstract class TestItem
{
    private int _testId;
 
    public TestItem(int testIdValue)
    {
        _testId = testIdValue;
    }
 
    public int TestId
    {
        get
        {
            return _testId;
        }
        set
        {
            _testId = value;
        }
    }
 
    public abstract string Description { get; set; }
 
    public abstract void RunTest(int i);
 
    public abstract string this[int index] { get; set; }
}

Write a C program to swap two variables without using a temporary variable.

This method is also quite popular
a=a+b;
b=a-b;
a=a-b;

What is heap and stack?


The stack is a place in the computer memory where all the variables that are declared and initialized before runtime are stored. The heap is the section of computer memory where all the variables created or initialized at runtime are stored.

Swapping three variable without using temp variable 

a = 2 b = 1 c = 3 

a = a+b+c = 6

b = a -b-c = 2 
c = a -b- c = 1
a = a-b-c = 3 

After swapping 

a = 3 ; b = 2 ; c = 1



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?
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:
   
   
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]);
 
http://www.c-sharpcorner.com/uploadfile/mahesh/workingwitharrays11232005064036am/workingwitharrays.aspx

Downloading MySQL Installation Wizard


For downloding MySQL with instaltion wizard cick here


There are several ways to populate DropDownList control. In this article autor have tried to cover some of them including populating DropDownList manually, programmatically, through xml, database, arraylist, hashtable. Author have also covered how to specify different background color of every items of the DropDownList and how to generate DropDownList on the fly. At last he have covered how to get its index, text and value properties.

http://www.dotnetfunda.com/articles/article30.aspx

Share point Interview Questions

SharePoint Interview question/answers Q. What are WebParts?
Ans. Web Parts are self-contained packages of user interface that can be dropped onto a SharePoint Web Part page to provide discrete set of functionality to the users. They can simply be described as re-usable Code units.

Q. What are Features?
Ans. Features represent a set of functionality (code) that can be activated and de-activated at various levels in SharePoint. Using Features, you can do everything from adding a link to the Site Settings page to creating a complete fully functioning Project suite that can be added to any SharePoint site. Developers can scope feature to the following level -
. Web
. Site
. WebApplication
. Farm

Q. What are Solutions?
Ans. Solutions are the container packages for Features. Solution basically, is a cabinet (.cab) file with extension .wsp which contains various components needed to be deployed(features, webparts, custom forms etc) along with files that describe some important metadata about those Components. Once a Solution is installed on a server in the farm, you can deploy it to any webapplication from your Solution Management.

Q. What is a .ddf file and what does it have to do with SharePoint Solution creation?
Ans. A .ddf file is a data directive file which describes the files need to be deployed and their destination (in SharePoint). .ddf is used when building the SharePoint solution. This file is a parameter to makecab.exe which outputs the wsp file.

Q. What is the difference between a site and a web in SharePoint?
Ans. A site in sharePoint is a site collection. It is an object of SPsite class in sharepoint. A Web however, is simply a blank site within that site collection. Web is a Part of SPweb class, thus represents a site within a site collection.

Q. What is CAML?
Ans. CAML stands for Collaborative Application Markup Language and is an XML-based language that is used in Microsoft Windows SharePoint Services to define sites and lists for E.g. fields, views, or forms etc. Developers mostly use CAML to write Queries to retrieve data from Lists\libraries.

Q. What is Custom action?
Ans. Represents a link, toolbar button, menu item, or any control that can be added to a toolbar or menu that appears in the UI. For e.g. "New Folder" button in your document library is a custom action or "View All Site Content" in your Site Settings is a custom action.

Q. What are Master pages in SharePoint?
Ans. These are the pages that provide a consistent layout and appearance (look and feel) for SharePoint sites. A master Page consist of a Site logo, Top navigation, left navigation(some cases) and a footer. In SharePoint Master Pages are stored in _catalogs folder or Master Page Gallery from UI.

Q. What are Layout Pages in SharePoint?
Ans. A Layout page defines the Layouts(structure including Webpart zones) of a content page in SharePoint. Layout pages are not same as Master Page. A Layout Page is contained inside the content area surrounded by mater Page.

Q. What is a SharePoint Theme?
Ans. A Theme is a group of files (CSS, images) that allow you to define the appearance (look and feel) of content pages in SharePoint. A Theme defines the design of various components for e.g. Content Page background-color,button color,webpart title color etc to give a different look and feel to your site.

Q. What is a web part zone?
Ans. Web part zones are what your web parts reside in. Each webpart zone can contain number of webparts and can be positioned in a specific way to create a webpart Layout Page.

Q. What is Business Data Catalog or BDC ?
Ans. It is a shared service that enables Office SharePoint Server 2007 to display business data from various back-end servers into a SharePoint page. Business Data Catalog or BDC provides built-in support for displaying data with various webparts and list\list columns that can help in easy creation of dashboards with data from your SQL, web services, SAP, Siebel, or any other line-of-business (LOB) applications.

Q What is a Site definition?
Ans. A Site definition is a collection of Files such as ONET.XML which defines the Site template for e.g. Team Sites used to create a Site in SharePoit. All the out-of-box site Templates like Blog,Wiki,Team Site etc can be found in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\

Q What is a Site Template?
Ans. Any Site along with the content can be saved as a template. If a site is saved as a Template it is stored in Site templates folder as a .stp file. This template is then re-used to create a new site which will have the pre-saved settings.

Q. What are content types?
Ans. A content type is a flexible and reusable template of type list item or document that defines the columns and behavior for an item in a list or a document in a document library. For example, you can create a content type for a Requirement document with a columns such LOE,Version,Approver,Date Created,Date Revised etc and this can be re-used in various document libraries.

Q. what is Central administration?
Ans. This is a site used by admins to mange and configure settings for SharePoint web applications or the whole farm.

Q. What are event receivers or event Handlers in SharePoint?
Ans. Event Receivers or Event handlers are created to handle the basic actions or events against an item,list\library, a web or a site. There are two kinds of events in sharepoint.

Synchronous Events: Like Itemadding (not added yet), Uploading (document not uploaded yet) etc.

Asynchronous Events: ItemAdded (after item is added), Uploaded(after a document is uploaded)

Events receivers can be written to override an event for e.g. ItemAdded event to change the name of an Item once it is added.

Q. What is stsadm?
Ans. It is a Command-line tool used for administration of Office SharePoint 2007 (or MOSS 2007) servers and sites. Basic operations like adding a solution or installing activating and feature is usually done by stsadm.

Q. What permissions are required to perform stsadm operations?
Ans. You need to be a member of WSS_ADMIN_WPG group to perform deployments for sharepoint server. Also, you need to be added into administrators group on a computer on which SharePoint Server or WSS 3.0 is installed. In addition to this you definitely need access to the required sharepoint databases so that you should not get errors while deploying sharepoint solutions.

Q. Where is it located?
Ans. You will normally, find it under C:\Program Files\Common Files\ shared\web server extensions\12\bin.

Q What is a DWP?
Ans. Its a webpart file extension.

Q What is the GAC?
Ans. Global Assembly Cache folder (or assembly) stores the strongly typed signed assemblies for webparts or other sharepoint components(which require full trust) for services to share them.

Q. What are Application Pages, Site Pages and Content Pages?

Ans.

Application Pages - An application page is deployed once per Web server and cannot be customized on a site-by-site basis. They stay in 12 hive folder structure, mostly under layouts folder.

Site Pages - These are pages that make up the site interface and are specific to one site or site collection.They mostly get stored in the content database of the site collection.

Content Pages - Site Page which contains webpart or other custom components. This Page is stored in database. They mostly get stored in the content database of the site collection.

Q.What are the Permission levels in SharePoint?
Ans. Permission levels in SharePoint are -

* Limited Access - They can view Application Pages, Browse User Information, Use Remote Interfaces, Use Client Integration Features etc.

* Reader - Limited Access permissions plus: View Items, Open Items, View Versions, Create Alerts, Use Self-Service Site Creation, View Pages.

* Contributor - Read permissions plus: Add Items, Edit Items, Delete Items, Delete Versions, Browse Directories, Edit Personal User Information, Manage Personal Views, Add/Remove Personal Web Parts, Update Personal Web Parts.

* Design - Contribute permissions plus: Manage Lists, Override Check Out, Approve Items, Add and Customize Pages, Apply Themes and Borders, Apply Style Sheets.

* Administrator - Has full control of the Web site.

* Full Control - All permissions.

Q. What are Site Columns?
Ans. Site columns are pre-defined data columns(along with default values) which are re-used in various content types. A Content type is usually a collection of site columns. For e.g. you can create a site column "Category" with a choice datatype along with the pre-defined values "It","Hr". This column then can be added to any content type in your list or library.

Q. What does each individual Site collection offers?
Ans. An Individual Site collection offers following :
For the Users:
Dedicated Recycle bins
Dedicated usage Reports
Distributed administration (site collection administrators)
Dedicated search scopes, keywords, and best-bets
Custom feature deployments
Dedicated language translation maintenance
Dedicated galleries for web parts, master pages, content types, site columns, site templates, and list templates
Dedicated shared libraries, such as site collection images and site collection styles
Dedicated real estate (Self Containment)

For the IT Administrators:
Site quota templates
Distributed administration
Site locking
Database maintenance options
Backup / Restore abilities
Content Deployments
InfoPath forms services global template targeting

Q. When would you use a Different Site Collection for you new site?.
Ans. We would prefer to make our new site in a seprate site collection for the following are the reasons:
1. Site quotas is one of the reasons. The issue is the recycle bin is based on site collections and the quota for a site collection. If everyone shares a site collection, then they share the recycle bins storage size.

2. Delegated Security and distributed administration is the next big thing. For eg, you have a IT department that doesn't know who should be able to see what content, besides how it should be organized. This is the job of the content owners and users. SharePoint site collections offers IT the ability to create a site collection for a project, team, department, document, or whatever the needs are, then assign an owner and hand it off to them.

3. In addition to these two if you need to separate the content between databases because of space issue.

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...