Mar 31


[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags:

Mar 25
 

Why Girls Don't Marry Software Guys !

 
 
  
 


[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags:

Mar 09
Student Action Committee are scrutinizing the Goverment Stategy and we have come up with a tentative sechdule of Long March +Dharna. Those of you who live in LAHORE will report to the busses at 5 AM on 16th March, 2009 at 5 - ZAMAAN PARK opposit Kannal, Lahore.


Kindly Report on Time so we can avoid Hassels.

ThankYou.

Important:

Those of you who are confirm about thier Participation. please reply this email.

Regards

Abdullah khan
0334-9813859
SAC


[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags:

Mar 07

Some interview questions

ASP.Net | General | Tips and Tricks | Visual Studio 121 Comments »

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Today I was surfing on the blog of Sheikh Ahmad and I saw some interview questions related to .Net. I will try to give answers of some of the questions.

Here is a question from his blog:

How can we get the variables of first form from second form without using query string and session etc?

Answer:

In these kinds of questions the interviewrs are actually try to detrmine that how much do you know about the .Net 2.0. It is very simple to get any control of the Page by using the this keyword or just from the ID of the control like

lbltest.Text = "hello";

But now the critical part of the question is that how to get the variables of first form from second form without using query string or session etc. This question itself suggests that we can access variable of one form from another using the query string or session etc but the interviewers has asked you not to use this approach.

What if I ecounter this problem in my work life? To solve this I will try to use an approach in which I can get the instance of the first page in the second page. Now the problem is that how to pass the instance of the first page in the second page without using query string or session etc. The answer is Cross Page posting which is a new feature of .Net 2.0. By default Controls like button , image button of ASP.Net post back to same page. If you want to post back to some other page instead of the current page then you can set the postbackUrl of these controls (i.e. Buttons,LinkButton,Image buttons). This is called the Cross Page posting and it is the feature of the .net 2.0. By using this appraoch you can navigate to the second page and in that second page you can access the first page too.

Suppose you have two pages page1.aspx and page2.aspx. In page1.aspx you have a button and a lable. Set the PostbackUrl of the button to page2.aspx and in the page2.aspx use previouse page property to get the previouse page's instance like this:

Page source = this.PreviousePage.

By using this approach you able to get the instance of the first page in the second page without using the Session or Query string. Now you can use this instance to get the variables, View state etc of the first page. 

 

Question: What are collections and why we use them?

Answer: Simply speaking Collection is a container which is used to hold the objects.

The second part of the question is that why we use them?

Well in programming we write differnt kinds of classes then we declare the objects of those classes. Those objects perform differnt functions and communicate with each other too and after performing their action they give output to some other kind of objects. So we use the container or collection to hold these objects. 

The question arise that what is the need of this container in the presense of the array? The answer is that array can not be used to hold differnt kinds of objects. Secondly we need to set the length of the array when we declare it but this is not the case with collection. The size of collection is dynamic. You just need to declare the collection and that is it. In collection you do not need to know that how many and what types of objects you are going to hold in collection.

Like other programming language C# has differnt kinds of container or collections i.e.

  • Stack
  • Queues
  • Hashtable
  • ArrayList 

Actually what ever you add in a collection becomes an object. It is said that every thing in .Net is an object, so what ever you add in a collection becomes object thus loosing its identity because in collection they are now in the form of object. The conversion of types into object is done by the .Net itself and it is called the Boxing. And this conversion of types to object is also called upcasting and it is always safe. Why it is always safe? Because you are converting the types into their super class (i.e. object of your class into System.Object) and we know that every thing in .net is derived from Object so this conversion will be safe always. Now when we get back our data from the collection it will be in the form of Object instead of the form in which we have added it in the collection. So when we get the data back from the collection then we have to cast it back into its orignal type. The conversion of the object into some specific type is called unboxing. Unboxing is also called downcasting. Downcasting should be done carefully because if you try to cast it into some wrong type then you will get the error. e.g. Casting the Circle into rectangle is wrong. So downcasting should be done carefully. Upcasting is done by the .Net itself and can be done programmatically but it is not dangeriouse while downcasting could be dangerious if not done properly.

That can be explained like "Circle and rectangle are always shape but it is not necessary that Shape is always a circle or rectangle"

Question: Shellow Copy vs Deep Copy?

I already wrote an article that how to impliment Shallow copy in .Net. Here is the Link of that article. It might help you.

http://www.shahidriaz.com/post/2008/12/07/ShallowCopy.aspx

 



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: ,

Mar 05

In this post i am going to show you how to implement a simple Linked List data structure in C++ using Visual Studio 2008. However, you can use your favorite IDE to build this example. You can also check the original post at my blog where complete source code of this post is available.

In simplistic view Linked List is a collection of individual List Nodes interconnected with each Node pointing to the Node ahead of it. So to get us started, we need List Nodes first and then we’ll build Linked List data structure using those.

Fire up your favorite IDE and create a new project and add a header file named Node.h. This header file contains the interface of the Node class. Following is the code for this header file.

   1: #pragma once
   2:  
   3: class Node
   4: {
   5:     public:
   6:         Node(void);
   7:         ~Node(void);
   8:  
   9:         int   get();
  10:         void   set(int   object);
  11:  
  12:         Node   * getNext();
  13:         void   setNext(Node   * nextNode);
  14:  
  15:     private:
  16:         int   object;
  17:         Node   * nextNode;
  18: };    

In the code snippet above, first data member is an integer type that will hold the node value and the second data member is a pointer to the next node in the list (Null if this is the last node in the list). Getter and Setter methods for the data members are also defined.

Now create a new class and name it Node.cpp. This will implement the interface defined in the Node.h header file. Following is the code for the Node.cpp.

   1: #include "Node.h"
   2:  
   3:     Node::Node(void){
   4:     }
   5:  
   6:     Node::~Node(void){
   7:     }
   8:     int   Node::get() { 
   9:         return   object; 
  10:     }
  11:  
  12:     void   Node::set(int   object) { 
  13:         this->object   =   object; 
  14:     }
  15:  
  16:     Node   * Node::getNext() { 
  17:         return   nextNode; 
  18:     }
  19:  
  20:     void   Node::setNext(Node   * nextNode) { 
  21:         this->nextNode   =   nextNode; 
  22:     }

To create a linked list of Nodes we have to create a List class. For that create a new header file named List.h and copy the following code snippet into it. Include the Node.h header file created earlier.

   1: #pragma once
   2: #include "Node.h"
   3: class List
   4: {
   5:     public:
   6:         List(void);
   7:         ~List(void);
   8:         void   add (int   addObject);
   9:         int    get();
  10:         bool   next();
  11:         friend void  traverse(List list);
  12:         friend List   addNodes();
  13:         void start();
  14:         void remove();
  15:         int length();
  16:  
  17:     private:
  18:         int      size;
  19:         Node *   headNode;
  20:         Node *   currentNode;
  21:         Node *   lastCurrentNode;
  22: };

In this code snippet there is one data member named size. It will hold the current size of the linked list. A part from that three Node pointer are declared pointing to the Head Node, Current Node and the Last Current Node as their names suggest. Two friend functions are declared namely traverse() and addnodes().In the second part I'll show you the implementation of the List class and i'll finish with testing the Linked List in main method



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: