0
iamscottj's Avatar
Light Poster
Interesting interview questions. It helped me remember all the answers. Thanks a lot. Would like to see some .NET 3.0 or 4.0 questions too.
0
GilbertoCode's Avatar, Join Date: Nov 2010
Newbie Member
Actually, Protected Internal can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.
0
tom7nuge's Avatar
Banned
great post. I like it
0
virender.ets's Avatar
Banned
It's great help to face the interview.
thanks
0
khadakbist's Avatar, Join Date: Feb 2011
Newbie Member
Here some more good questions questpond dot com
0
the_nell_87's Avatar, Join Date: Mar 2011
Newbie Member
Quote:
10.Can you store multiple data types in System.Array?
No.
While strictly true, the answer to that question is incorrect. There is nothing stopping you from declaring an array of objects, then populating it with a variety of different data types. For example, the following is perfectly legal:

Code:
object[] array = new object[] { 1, "abc", new Random() };
Of course, that's extremely bad practice, but the fact remains that you can do it.
0
srhone's Avatar, Join Date: Mar 2011
Newbie Member
Class question "Can you allow a class to be inherited, but prevent the method from being over-ridden?" answer (Yes. Just leave the class public and make the method sealed.) is wrong. You cannot use the "sealed" modifier in a public class that is not over-riding the class that implements the method or property that you want to seal. If you want to stop someone from over-riding a method or property just do not add the "virtual" modifier to it

The following will raise an error. If you switched the GetPerson in the Person class to include the "virtual" modifier then it would work.
public class Person{
public string GetPerson(){

}
}
public class Member: Person{
override public string GetPerson(){
}
}
0
sbsl's Avatar
Banned
Quote:
Originally Posted by Mutayyab Shah View Post
Anyone ans me that .what is different b/w mutable and immutable?

Mutable Objects: When you have a reference to an instance of an object, the contents of that instance can be altered
Immutable Objects: When you have a reference to an instance of an object, the contents of that instance cannot be altered
0
hitesh123's Avatar
Banned
great package of questions u have shared............. it will definately help c# bginner...
0
MarkC's Avatar, Join Date: Jan 2013
Newbie Member
Hieverybody,

Likethe_nell_87, I think the answer in 10th question is not ok (Can you storemultiple data types in System.Array?).
If you havea this hierarchy: class Person {}; class Male : Person {}; class Female : Person {}; each Maleor Female object is also a Person object.
With an ArrayListobject, I can insert multiple types of the same hierarchy, and then convert theArrayList to an Array using the base type of Person. The following code works fine:
Code:
class Person { }
    class Male : Person { }
    class Female : Person { }
 
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList al = newArrayList();
           al.Add(new Female());
           al.Add(new Male());
            Person auxp = new Person();
           al.Add(auxp);
            Array a = al.ToArray(auxp.GetType());
            foreach (Person p in a)
            {
                Console.WriteLine(p.GetType().ToString());
}
        }
    }
So, in myopinion the answer is yes.

Last edited by shabbir; 24Jan2013 at 09:22.. Reason: Code blocks