The blog has moved to the new site F10Debug.com

Thursday, April 23, 2015

What is Interface in C#.net ?

What is Interface in C#.net ?


Interface is a type which contains only the signatures/declaration of methods/functions, delegates or events.

Declaration /signature of methods meaning method having no implementation as follows,

void Display(string name);  //By Default interface member is Public

It does not contain implementation of methods. Implementation of the methods is done by the class that which implements the interface.

Interface is a contract that defines the signature of the functionality. So if a class is implementing
a interface it says to the outer world, that it provides specific behavior. 

Example: If a class is implementing ‘Idisposable’ interface that means it has a functionality to release unmanaged resources. Now external objects using this class know that it has contract by which it can dispose Un-used unmanaged objects. 

Important points to remember about Interface:

a)      Supports multiple interface (Single Class can implement multiple interfaces.)

b)      If a class implements an interface, then it has to provide implementation to all its methods.

c)       Contains declaration / signature of methods only, it does not contain implantation of methods.

d)      It cannot contain Data members like string name.

e)      By Default interface members are Public (We cannot set any access modifier to interface members).

f)       Interface cannot contain constructors.


Example: - Defining an Interface,
   
     interface IDisplay
     {
        string name(string name); //By Default interface members are Public

         int a ; // Error, It cannot contain Data members .  
     }

     class Demo : IDisplay
     {
        public string  name(string name) //Must be declare Public
        {
            return “” + name;
        }
     }

Note: If you know some points about interfaces, that i have missed, please comment. So that i will review and upload. 

Tuesday, April 21, 2015

What are abstract classes?

What is Abstract Class?

a)      Classes can be declared as abstract class by using abstract keyword.

b)      Abstract class is designed to act as a base class (to be inherited by other classes).Abstract class is a design concept in program development and provides a base upon which other classes are built.

c)      Abstract class does not allow creating instance or object of it; we must inherit to use it, as in figB.


d)      Abstract classes can have abstract methods as well as non-abstract methods (which must be implemented in the child class).





e)      A non-abstract class derived from an Abstract class must include implementations for all inherited abstract methods.



f)      An abstract class cannot be a sealed or static class.



g)   An abstract method cannot be private, protected or protected internal.



h)      An abstract member cannot be static.


Wednesday, April 15, 2015

Part 5: C#.Net interview question and answers



Part 1 - C#.Net interview questions and answers

Part 2 - C#.Net interview questions and answers

Part 3 - C#.Net interview questions and answers

Part 4 - C#.Net interview questions and answers

74. In which namespace, all .NET collection classes are contained?

75. What are methods?

76. Properties in C# and advantages of it ?

77. What are different types of arguments?

78. What is Out Keyword in C#?

79. What are access modifiers?
a) Public
b) Private
c) Protected
d) Internal
e) Protected Internal

80. How can we call the base method without creating an instance?

81. What is ‘this’ pointer?

82. Whether static method can use non static members?

83. How many instances can be created for an abstract class? Zero OR
Can we create object / instances of abstract class? No

84. Can a method be overloaded based on different return type but same argument type? No

85. What is the function of 'this' operator?

86. What are abstract methods?

87. What is difference between Static and Non-Static fields of a class?

88. What are inner classes and what is the practical implementation of inner classes?

89. Difference between bool and Boolean?

90. What is serialization? How do we implement serialization actually?

91. What’s the top .NET class that everything is derived from? System.Object.

92. What is the difference between int.Parse and int.TryParse methods?

93. Default modifier of Enum and Interface ? Public

94. What is the Default Modifier for Structure? Internal

95. What is the Default Modifier for methods, fields, and properties? Private

96. What is the escape sequence of null character? \0

97. IEnumarable vs Iqueriable?

98. system.string vs string?


Part 1 - C#.Net interview questions and answers

Part 2 - C#.Net interview questions and answers

Part 3 - C#.Net interview questions and answers

Part 4 - C#.Net interview questions and answers