Consider the class below
class joel
{
public int num = 0;
public void displaynum()
{
int num = 1;
}
public void displaynextnum()
{
num = 2;
}
}
What will below codes print and why?
1. joel j = new joel();
j.displaynum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
2. joel j = new joel();
j.displaynextnum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
Showing posts with label Interview question on instance variable. Show all posts
Showing posts with label Interview question on instance variable. Show all posts
Wednesday, January 16, 2008
Subscribe to:
Posts (Atom)