Tuesday, December 4, 2012

Hadoop Interview Questions


What are the default configuration files that are used in Hadoop 
As of 0.20 release, Hadoop supported the following read-only default configurations
- src/core/core-default.xml
- src/hdfs/hdfs-default.xml
- src/mapred/mapred-default.xml
How will you make changes to the default configuration files 
Hadoop does not recommends changing the default configuration files, instead it recommends making all site specific changes in the following files
- conf/core-site.xml
- conf/hdfs-site.xml
- conf/mapred-site.xml
Unless explicitly turned off, Hadoop by default specifies two resources, loaded in-order from the classpath:
- core-default.xml : Read-only defaults for hadoop.
- core-site.xml: Site-specific configuration for a given hadoop installation.
Hence if same configuration is defined in file core-default.xml and src/core/core-default.xml then the values in file core-default.xml (same is true for other 2 file pairs) is used.


Monday, December 3, 2012

Hadoop Interview Question

 Here are Some Hadoop Administration question you May expect.  answers you need to find.... :) i can give but i wont : if you find good answer share with me also :) hope you will right ? If you are not able to find let me know through comments i will post the answers too.


  • What is Hadoop? Brief about the components of  Hadoop.
  • What are the Hadoop daemon processes tell the components of Hadoop and functionality?
  • Tell steps for configuring Hadoop?
  • What is architecture of HDFS and flow?
  • Can we have more than one configuration setting for Hadoop cluster how can you switch between these configurations?
  • What will be your troubleshooting approach in Hadoop?
  • What are the exceptions you have come through while working on Hadoop, what was your approach for getting rid of those exceptions or errors?

Thursday, October 4, 2012

100 C Questions and Answers


(Q :  1)
Code:
int z,x=5,y=-10,a=4,b=2; 
z = x++ - --y * b / a;
What number will z in the sample code above contain? 
Option 1
Option 2
Option 3
10 [Ans] Corrected by buddy by running the program
Option 4
11 
Option 5
12 
____________________________________________________________

(Q :  2)
With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed? 

Tuesday, September 18, 2012

Demystifying Hadoop concepts Series: Safe mode

 

safemode

What is is safe mode of hadoop, may time we come across this exception “ org.apache.hadoop.ipc.RemoteException: org.apache.hadoop.hdfs.server.namenode.SafeModeException”  or some other exceptions Which contains safe mode in it Smile .

 

First let me tell what Safe mode is in context to Hadoop : as we all know Name node contains fsimage (metadata) of the data present on the cluster, which can be large or small based on the size of the cluster and the size of date present on the cluster, so when the name node starts it loads this fsimage and the edit logs from the disk in the Primary memory RAM for fast processing, and after loading it waits for data nodes to report about the present on those data nodes, so during this process that is loading the fsimage and edit logs and waiting for data nodes to report about the data block in safe mode, which is a read only mode for name node this is done to maintain the consistency of the data present, this is just like saying “ i will not receive any thing till i know what i already have”. And during this period no modification to the file blocks are allowed as to maintain the correctness of the data.

 

How long safemode exist :

Generally name node automatically comes out of safe mode in 30 seconds if all data present are consistent according the fsimage and the editlogs.

 

Related commands :

Put Namenode in Safemode: bin/hadoop dfsadmin –safemode

Leave Safemode : bin/hadoop dfsadmin -safemode leave

 

What to do if you encounter this exception :

 

First, wait a minute or two and then retry your command. If you just started your cluster, it's possible that it isn't fully initialized yet. If waiting a few minutes didn't help and you still get a "safe mode" error, check your logs to see if any of your data nodes didn't start correctly (either they have Java exceptions in their logs or they have messages stating that they are unable to contact some other node in your cluster). If this is the case you need to resolve the configuration issue (or possibly pick some new nodes) before you can continue.

 



Tuesday, June 5, 2012

What do you mean by Object Slicing?


When a derived class object is assigned to a base class, only the base class's part of content in the derived object are copied to the base class, leaving behind the derived class specific contents. This is referred as Object Slicing.

Class BaseClass
{
public int i;
};

class DerivedClass : public BaseClass
{
public int j;
};

int main()
{
BaseClass ObjectOfB;
DerivedClass ObjectOfD;
ObjectOfB = ObjectOfD;
//Here ObjectOfD contains both i and j.
//But only i is copied to ObjectOfB.
}

What is difference between overloading and overriding?



Having same name methods with different parameters is called overloading, while having same name and parameter functions in base and drive class called overriding.

Tuesday, May 1, 2012

How to : Variable Prameters in c# function.

 

We can use “params” to enable a method to accept variable number of parameters. For using this we can send comma parameter list as somefunction(1,2,3,1,3,4) to the method.

Thursday, April 19, 2012

how to calculate median in Hive

Use the following function :


percentile(BIGINT col, p)

and set p to be 0.5



Will calculate median :)

Tuesday, April 17, 2012

What is the difference between HDFS and NAS ?

    The Hadoop Distributed File System (HDFS) is a distributed file system designed to run on commodity hardware. It has many similarities with existing distributed file systems. However, the differences from other distributed file systems are significant. Following are differences between HDFS and NAS
    • In HDFS Data Blocks are distributed across local drives of all machines in a cluster. Whereas in NAS data is stored on dedicated hardware.
    • HDFS is designed to work with Map Reduce System, since computation are moved to data. NAS is not suitable for Map Reduce since data is stored separately from the computations.
    • HDFS runs on a cluster of machines and provides redundancy using replication protocol. Whereas NAS is provided by a single machine therefore does not provide data redundancy.

What is a Job Tracker in Hadoop? How many instances of Job Tracker run on a Hadoop Cluster?

    Job Tracker is the daemon service for submitting and tracking Map Reduce jobs in Hadoop. There is only One Job Tracker process run on any hadoop cluster. Job Tracker runs on its own JVM process. In a typical production cluster its run on a separate machine. Each slave node is configured with job tracker node location. The Job Tracker is single point of failure for the Hadoop Map Reduce service. If it goes down, all running jobs are halted. Job Tracker in Hadoop performs following actions(from Hadoop Wiki:)
    • Client applications submit jobs to the Job tracker.
    • The JobTracker talks to the NameNode to determine the location of the data
    • The JobTracker locates TaskTracker nodes with available slots at or near the data
    • The JobTracker submits the work to the chosen TaskTracker nodes.
    • The TaskTracker nodes are monitored. If they do not submit heartbeat signals often enough, they are deemed to have failed and the work is scheduled on a different TaskTracker.
    • A TaskTracker will notify the JobTracker when a task fails. The JobTracker decides what to do then: it may resubmit the job elsewhere, it may mark that specific record as something to avoid, and it may may even blacklist the TaskTracker as unreliable.
    • When the work is completed, the JobTracker updates its status.
    • Client applications can poll the JobTracker for information.

What is compute and Storage nodes?

Compute Node: This is the computer or machine where your actual business logic will be executed.

Storage Node: This is the computer or machine where your file system reside to store the processing data.

In most of the cases compute node and storage node would be the same machine.

What is Map Reduce ?

Map reduce is an algorithm or concept to process Huge amount of data in a faster way. As per its name you can divide it Map and Reduce.

  • The main Map Reduce job usually splits the input data-set into independent chunks. (Big data sets in the multiple small datasets)
  • Map Task: will process these chunks in a completely parallel manner (One node can process one or more chunks).
  • The framework sorts the outputs of the maps.
  • Reduce Task : And the above output will be the input for the reduce tasks, produces the final result.

Your business logic would be written in the Mapped Task and Reduced Task.

Typically both the input and the output of the job are stored in a file-system (Not database). The framework takes care of scheduling tasks, monitoring them and re-executes the failed tasks.

What is Hadoop framework

Hadoop is a open source framework which is written in java by apache software foundation. This framework is used to write software application which requires to process vast amount of data (It could handle multi TB of data). It works in-parallel on large clusters which could have 1000 of computers (Nodes) on the clusters. It also process data very reliably and fault-tolerant manner. See the below image how does it looks.

Thursday, April 12, 2012

What is Strongly Typed.


  1. This means that the data type, is predefined, which prevents programmers to invent and add new data type, to enforce this the language compiler comes in play, it takes care of checking the typed at the compile time only.
  2. In more clear way we can say that the programming language is strongly typed if it does not allows to define a variable with a data type, we can take and example of c, in which whenever we declare a variable we need to specify its data type also e.g.: int a, char b, but some other languages are loosely typed as we can just give var a, or $var  which can hold any data type assigned.
  3. One more explanation is that in strongly typed the data type is checked at compile time but in loosely typed this done at runtime.

Why Generic type???


  1. It helps us to separate logic from data type, means no matter what type of data type we are passing to method, will be handled using the same function.
  2. In other way, we can avoid polymorphism, means only one function can handle different data type rather than defining many function with different kind of data type.
  3. Generic type invocation as being similar to an ordinary method invocation, but instead of passing an argument to a method, you're passing a type argument
So how to use it,

Sunday, April 1, 2012

What is the difference between const and static readonly?

The difference is that the value of a readonly field is set at run time, so it can have a different value for different executions of the program. However, the value of a const field is set to a compile time constant.

 

 

Readonly instance fields

  • Must have set value, by the time constructor exits
  • Are evaluated when instance is created

How to make a class immutable ??

Immutable class is a type of class whose object cant be modified after their creation, which means only constructor will be able to modify or write the fields values of the class.

Java :

In java best way to make a class as immutable is to declare all the fields or variables of the class as final, so declaring final, will prevent the variable or fields to be modified outside the constructor, it will also look after the memory synchronization.

 

Code Example :

How to check if a link list is circular of is a loop??

This is one of the important question interviewers askes and you are supposed to at least give a logical answer to it, so the logic behind this is to “ Create two markers (pointers) move one pointer faster other slower in a loop, so if these two pointers meets at some point, before the link list ends (while not null) means the link list is circular else if the two pointer meets when the link list ends means while null becomes true means the link list is not circular.

 

Example Code :

 

while (SlowPointer) {
SlowPointer = SlowPointer->next;
FastPointer = FastPointer->next;
if (FastPointer) FastPointer=FastPointer->next;
if (SlowPointer == FastPointer) {
print ("circular\n");
}
}

Tuesday, March 27, 2012

Where is pass by reference is useful?

1.
Suppose you have large object to pass to a function, better to pass by reference instead of passing bye value or the object itself.

2.
Least Memory Management.

3.
No 0 values possible -> Called function will know that the object have been created and you are passing address of that object.

4.
New variable are not created, rather already created objects or variable are used.

5.
We can return multiple values from a function.

6.
It allows us to have the function change the value of the argument, which is sometimes useful.

7.


more practical reason will come soon ......

Thursday, March 1, 2012

Difference between ref and out parameters in .NET


The out and the ref parameters are used to return values in the same variables, that you pass an an argument of a function. These both parameters are very useful when your function needs to return more than one values.


                The out Parameter
The out parameter can be used to return the values in the same variable passed as a parameter of the function. Any changes made to the parameter will be reflected in the variable.

Sunday, February 5, 2012

Disscuss access specifier in c#


Access modifier specify the accessibility of a variable or and object. That means who can access the object and how can it be accessed.which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:

public : 
The type or member can be accessed by any other code in the same assembly or another assembly that references it.

Saturday, February 4, 2012

Write a code to get file name from file path in c#


  String filePath = @"c:\file\neme\file.txt";

=> filePath.Split('\\')[filePath.Split('\\').Length-1]     ---->   Will give file name with extension

=> (filePath.Split('\\')[filePath.Split('\\').Length-1]).Split('.')[0] --> Will give file name without extension 


=> filePath.Split('\\')[0]  --> Will give drive letter 


What are Delegates?



A delegate is a form of type-safe function pointer used by the .NET Framework. Delegates specify a method to call and optionally an object to call the method on. They are used, among other things, to implement callbacks and event listeners. It encapsulates a reference of a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.

Basically it is similar like the old "C" age function pointer, where functions can be assigned like a variable and called in the run time based on dynamic conditions. C# delegate is the smarter version of function pointer which helps software architects a lot, specially while utilizing design patterns.

At first, a delegate is defined with a specific signature (return type, parameter type and order etc). To invoke a delegate object, one or more methods are required with the EXACT same signature. A delegate object is first created similar like a class object created. The delegate object will basically hold a reference of a function. The function will then can be called via the delegate object.



Syntax :

How a thread is created ?

First, create a new Thread Start delegate. The delegate points to a method that will be executed by the new thread. Pass this delegate as a parameter when creating a new Thread instance. Finally, call the Thread.Start method to run your method.


In Detail :


1. Create a System.Threading.Thread object.
2. Create the call back function
3. Starting the Thread




Thread newThread= new Thread(new ThreadStart (MyCallbackFunction));


                 /  \                                                      /  \
                   |         (1)                                            |          (2)




newThread.Start()


        /  \
          |        (3)







What is thread join?

Stops of prevents the calling thread until a called thread terminates, and side by side continuing to perform standard COM and SendMessage pumping.


Syntax of this method :


// create a new thread object from thread class
Thread threadToJoin  =  new Thread(threadmethod); 


//Thread have come to running state.
threadToJoin.Start();   


 // Wait for foreground thread to end.
threadToJoin.Join()
^
 |   ____ so this threadToJoin thread will wait, until other threads are terminated.


Example : Suppose you are cooking something, and in between you need something to finish cooking, so you send your servant to get that, so you will call your cooking thread .join to wait till the servant thread not finished/ servant does not come with required item, and when servant arrives with the item servant thread terminates and your thread can continue.
               
void threadmethod()
{
    //method body
}




Tuesday, January 24, 2012

What’s the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.

What is an ABC?

An abstract base class.
At the design level, an abstract base class (ABC) corresponds to an abstract concept. If you asked a mechanic if he repaired vehicles, he'd probably wonder what kind-of vehicle you had in mind. Chances are he doesn't repair space shuttles, ocean liners, bicycles, or nuclear submarines. The problem is that the term "vehicle" is an abstract concept (e.g., you can't build a "vehicle" unless you know what kind of vehicle to build). In C++, class Vehicle would be an ABC, with Bicycle, SpaceShuttle, etc, being derived classes (an OceanLiner is-a-kind-of-a Vehicle). In real-world OO, ABCs show up all over the place. 

At the programming language level, an ABC is a class that has one or more pure virtual member functions. You cannot make an object (instance) of an ABC.

What is a "virtual constructor"?

An idiom that allows you to do something that C++ doesn't directly support.
You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing), or a virtual create() member function (for the default constructor).
 class Shape {
 public:
   virtual ~Shape() { }                 
// A virtual destructor
   virtual void draw() = 0;             
// A pure virtual function
   virtual void move() = 0;
   
...
   virtual Shape* clone()  const = 0;   
// Uses the copy constructor
   virtual Shape* create() const = 0;   
// Uses the default constructor
 };

 class Circle : public Shape {
 public:
   Circle* clone()  const;   
// Covariant Return Types; see below
   Circle* create() const;   
// Covariant Return Types; see below
   
...
 };

 Circle* Circle::clone()  const { return new Circle(*this); }
 Circle* Circle::create() const { return new Circle();      } 
 

When should my destructor be virtual?

When someone will delete a derived-class object via a base-class pointer.
In particular, here's when you need to make your destructor virtual:
  • if someone will derive from your class,
  • and if someone will say new Derived, where Derived is derived from your class,
  • and if someone will say delete p, where the actual object's type is Derived but the pointer p's type is your class.

How can a member function in my derived class call the same function from its base class?

Use Base::f();
Let's start with a simple case. When you call a non-virtual function, the compiler obviously doesn't use the virtual-function mechanism. Instead it calls the function by name, using the fully qualified name of the member function. For instance, the following C++ code...
 void mycode(Fred* p)
 {
   p->goBowling();  
 pretend Fred::goBowling() is non-virtual
 }
...might get compiled into something like this C-like code (the p parameter becomes the this object within the member function):
 void mycode(Fred* p)
 {
   __Fred__goBowling(p);  
 pseudo-code only; not real
 } 
 

What happens in the hardware when I call a virtual function? How many layers of indirection are there? How much overhead is there?

The answer is entirely compiler-dependent, so your mileage may vary, but most C++ compilers use a scheme similar to the one presented here.
Let's work an example. Suppose class Base has 5 virtual functions: virt0() through virt4().
 // Your original C++ source code

 class Base {
 public:
   virtual 
arbitrary_return_type virt0(...arbitrary params...);
   virtual 
arbitrary_return_type virt1(...arbitrary params...);
   virtual 
arbitrary_return_type virt2(...arbitrary params...);
   virtual 
arbitrary_return_type virt3(...arbitrary params...);
   virtual 
arbitrary_return_type virt4(...arbitrary params...);
   
...
 }; 

What's the difference between how virtual and non-virtual member functions are called?

Non-virtual member functions are resolved statically. That is, the member function is selected statically (at compile-time) based on the type of the pointer (or reference) to the object. 

In contrast, virtual member functions are resolved dynamically (at run-time). That is, the member function is selected dynamically (at run-time) based on the type of the object, not the type of the pointer/reference to that object. This is called "dynamic binding." Most compilers use some variant of the following technique: if the object has one or more virtual functions, the compiler puts a hidden pointer in the object called a "virtual-pointer" or "v-pointer." This v-pointer points to a global table called the "virtual-table" or "v-table." 

How can C++ achieve dynamic binding yet also static typing?

When you have a pointer to an object, the object may actually be of a class that is derived from the class of the pointer (e.g., a Vehicle* that is actually pointing to a Car object; this is called "polymorphism"). Thus there are two types: the (static) type of the pointer (Vehicle, in this case), and the (dynamic) type of the pointed-to object (Car, in this case). 

What is a "virtual member function"?

A virtual function allows derived classes to replace the implementation provided by the base class. The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class, even if the object is accessed by a base pointer rather than a derived pointer. This allows algorithms in the base class to be replaced in the derived class, even if users don't know about the derived class.

What is the difference betweein pointer to constant or a constant pointer?

Lets Take an example :
We have :

char *const p1="Shashwat";
char const* p2="Shriparv";

How do I call a C++ function from C?

Just declare the C++ function ``extern "C"'' (in your C++ code) and call it (from your C or C++ code). For example:
 // C++ code:

 extern "C" void f(int);

 void f(int i)
 {
  // ...
 }
Now f() can be used like this:
 /* C code: */

 void f(int);
 
 void cc(int i)
 {
  f(i);
  /* ... */
 }

Why can't I overload dot, ::, sizeof, etc.?

Most operators can be overloaded by a programmer. The exceptions are
 . (dot)  ::  ?:  sizeof
There is no fundamental reason to disallow overloading of ?:. I just didn't see the need to introduce the special case of overloading a ternary operator. Note that a function overloading expr1?expr2:expr3 would not be able to guarantee that only one of expr2 and expr3 was executed. Sizeof cannot be overloaded because built-in operations, such as incrementing a pointer into an array implicitly depends on it. Consider:
 X a[10];
 X* p = &a[3];
 X* q = &a[3];
 p++; // p points to a[4]
  // thus the integer value of p must be
  // sizeof(X) larger than the integer value of q

What is the difference between new and malloc()?

malloc() is a function that takes a number (of bytes) as its argument; it returns a void* pointing to unitialized storage. new is an operator that takes a type and (optionally) a set of initializers for that type as its arguments; it returns a pointer to an (optionally) initialized object of its type. The difference is most obvious when you want to allocate an object of a user-defined type with non-trivial initialization semantics. Examples:
 class Circle : public Shape {
 public:
  Cicle(Point c, int r);
  // no default constructor
  // ...
 }; 
 

What's the value of i++ + i++?

It's undefined. Basically, in C and C++, if you read a variable twice in an expression where you also write it, the result is undefined. Don't do that. Another example is:
 v[i] = i++;
Related example:
 f(v[i],i++);
Here, the result is undefined because the order of evaluation of function arguments are undefined. Having the order of evaluation undefined is claimed to yield better performing code. Compilers could warn about such examples, which are typically subtle bugs (or potential subtle bugs). I'm disappointed that after decades, most compilers still don't warn, leaving that job to specialized, separate, and underused tools.

Thursday, January 19, 2012

How to: Add a Content Type to a SharePoint List using C#

Create a SharePoint 2010 Project

In this task, you create an empty SharePoint 2010 project in Microsoft Visual Studio 2010.
To create the SharePoint project
  1. To start Visual Studio 2010, click the Start Menu, click All Programs, click Microsoft Visual Studio 2010, and then click Microsoft Visual Studio 2010.
  2. On the File menu, point to New, and then click Project.
  3. In the New Project dialog window, in the Installed Templates section, click Visual C#, click SharePoint, and then click2010.
  4. Select Empty SharePoint Project from the project items.
  5. In the Name box, type CreateContentType and then click OK.
  6. In the SharePoint Customization Wizard, type the local Web site that you want to use for this exercise (such as http://localhost/SampleWebSite).
  7. For the trust level, select Deploy as a farm solution and then click Finish.

Create a Content Type

Monday, January 16, 2012

What are Satellite Assemblies?


A .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user selects to view the application in that language. In general, assemblies should contain culture-neutral resources. If you want to localize your assembly (for example use different strings for different locales) you should use satellite assemblies.




This means that you develop your application in a default language and add flexibility to react with change in the locale. Say, for example, you developed your application in an en-US locale. Now, your application has multilingual support. When you deploy your code in, say, India, you want to show labels, messages shown in the national language which is other than English.
Satellite assemblies give this flexibility. You create any simple text file with translated strings, create resources, and put them into the bin\debug folder. That's it. The next time, your code will read the CurrentCulture property of the current thread and accordingly load the appropriate resource.

Tell Something about class/object life cycle...





  1. Load the assembly
  2. Execute static initialisers
  3. "new" call:
    • allocate memory
    • execute non-static initialisers
    • execute constructor
  4. the instance is now ready to be used
  5. after the last reference to the object has vanished: if the object has no finalizer, it is now ready for collection; if the object has a finalizer, it is put on the finalizer queue.
  6. (optional) the objects from the finalizer queue have their finalizer called in a special thread; if there is still no reference from the application to the object, it too becomes now eligible for garbage collection
  7. the garbage collector deallocates memory

Sunday, January 15, 2012

What is Singleton Class in C++?

A class whose number of instances that can be instantiated is limited to one is called a singleton class. Thus, at any given time only one instance can exist, no more.

 The singleton design pattern is used whenever the design requires only one instance of a class. Some examples:
  • Application classes. There should only be one application class. 
  • Logger classes. For logging purposes of an application there is usually one logger instance required.
There are several ways of creating a singleton class. The most simple approach is shown below:


class Singleton
{
public:
static Singleton& Instance()
{ static Singleton singleton;
return singleton;
}
// Other non-static member functions
private:
Singleton() {}; // Private constructor
Singleton(const Singleton&); // Prevent copy-construction
Singleton& operator=(const Singleton&); // Prevent assignment
};



Saturday, January 14, 2012

What is difference between dot net framework 3.5 and 4.0?



ASP.NET 3.5 is having the following main features which are not availablle in the prior releases


1) AJAX integration

2) LINQ
3) Automatic Properties
4) Lambda expressions



I hope it would be useful for everyone to know about the differences about asp.net 3.5 and its next version asp.net 4.0



Because of space consumption I'll list only some of them here.



1) Client Data access:


ASP.NET 3.5: There is no direct method to access data from client side. We can go for any of these methods


Tell something about View State in Asp.Net

This is used by an ASP.NET Web page to persist changes to the state of a Web Form across postbacks.  The view state of a page is, by default, placed in a hidden form field named __VIEWSTATE. The load view state stage only happens when the page has been posted back. During this stage, the view state data that had been saved from the previous page visit is loaded and recursively populated into the control hierarchy of the Page. It is during this stage that the view state is validated.  It provide state to a webpage.


As we know A Web application is stateless. A new instance of the Web page class is created every time that the page is requested from the server. This would ordinarily mean that all information in the page and in its controls would be lost with each round trip. For example, by default if a user enters information into a text box on an HTML Web page, that information is sent to the server. However, it is not returned to the browser in the response.
To overcome this intrinsic limitation of Web programming, the ASP.NET page framework includes several state-management features to preserve page and control values between round trips to the Web server.


What Happens with View State

What is post back in Asp.Net


PostBack is the name given to the process of submitting an ASP.NET page to the server for processing . PostBack is done if certain credentials of the page are to be checked against a database (such as verification of username and password). This is something that a client machine is not able to accomplish and thus these details have to be ‘posted back’ to the server.
A simple example to illustrate the usage of PostBack is a login page. After the user has typed his username and password, he clicks on the ‘Login’ button. Upon the click, the page is sent to the server to check against the database/XML file to check if the user with supplied details is an authenticated user.
Then there arise certain events ( Listbox Index Changed,RadioButton Checked etc..) in an ASP.NET page upon which a PostBack might be needed. Consider the case in which you have 2 ComboBoxes. Let us say the first ComboBox asks you for the Country you reside in and the second one asks you for the State/Province in that country. Based upon the Country you select, the list of States/Provinces must be shown. Thus, in order to fill the values in the second ComboBox, the selection in the first ComboBox must be known to the server. Thus, as and when an item is selected in the first ComboBox, a PostBack must be done and the appropriate list of items must be filled in the second ComboBox.

How page request is handled in Asp.Net

ASP.NET Page Handling








Click here for larger image.




ms972976.viewstate_fig02(en-us,MSDN.10).gif


When to use Abstract Class and when to use Interface in project?

Use interface when you do not want to give any implementation and use abstract class when you want to give some common implementation that would be used by classes derived from that abstract class. An abstract class can be skeleton implementation of existing interface. 




Use abstract clas for "is A" relationship,  while use interfaces for "Can do" relationship.

Example:



Live

Your Ad Here