Sunday, January 20, 2008

Qusetion for Dot Net Interview (Part 3):

---// Abstract Class \\---
-- Abstract class should have one or more completed methods but at least one or more uncompleted methods and these uncompleted method must be preceded by the key word abstract.
-- Methods of the abstract class must take the keyword abstract (the method without immplementation)
-- If all the methods of an abstract class are uncompleted then it is the same as an interface, but there is a restriction that it cannot make a class inherit from it,which means it can not work as a base class.
-- I can inherite from abstract class to override its methods.
-- In abstract class i can define fields but must be protected
-- I can't create object from abstract class
-- An abstract class can contain fields, constructors, or destructors and implement properties -- abstract class can implement a property
-- An abstract class cannot support multiple inheritance
-- Abstract classes are faster than interfaces -- Abstract class can inherite from more than one Interface class
-- An abstract class can inherit from a class and one or more interfaces classes


---// Interface Class \\----
-- An interface has the definition of the methods without the body (uncomplited methods or method without immplementation)
-- In Interface class i can't define fields.
-- I can inherite from Interface class to override the methods (methods without body)
-- I can't create object from Interface class but i can create object from class which inherite from Interface class to access Interface class methods
-- An interface can not contain fields, constructors, or destructors and it has only the property's signature but no implementation
-- interface can support multiple inheritance from other interface classes
-- Interface class can only inherit from another Interface
-- An Interface class can contain only property definitions without immplement.


---// Sealed Class \\---
-- A sealed class cannot be inherited. It is an error to use a sealed class as a base class.
-- Use the sealed modifier in a class declaration to prevent inheritance of the class.
-- I can create object from sealed class but i can't override its method as i can't inherite from it

--* A nested class: is a class defined within the scope of another class

--* A derived class : inherits all of the member variables and methods of the base class from which it is derived.

--* What is Collection:
1) .Net framework has provided us with many classes like ArrayList, BitArray, HashTable, SortedList, Queue and Stack are some of them.
2) They are all included in System.Collections namespace.

--* what is difference between Array and Arraylist?
1) An array contain only one datatype
2) An array doesn't increase or decrease the size dynamically
3) An arraylist contain more than one datatype
4) An arraylist increase or decrease the size dynamically
5) Arrays cannot be changed in size at runtime
6) Array must has fixed size but Arraylist no
7) Arrays are not dynamic in nature and do not allow the user to remove an element easily

--* What is different between nested class and derived class:
1) A nested class: is a class defined within the scope of another class
2) A derived class: is a class that inherits all of the member variables and methods of the base class

--* Different Between Int.parse and Convert.ToInt32 :
Both(Convert.ToInt32 and int.Parse) will return the same result inmost of the cases.
But null is handled differently.Consider the following example…
string strCount="32";
int count1 = Convert.ToInt32(strCount);
int count2 = int.Parse(strCount);
If you print the result it will be same result which is 32.
If suppose the string is the null
Convert.ToInt32 will return zero.
but the int.Parse will throw ArgumentNullException error.
string strCount=null;
int count1 = Convert.ToInt32(strCount);// zero
int count2 = int.Parse(strCount); // Error

No comments: