An interface in C# is a type just like class is a type. The difference between interface and class is that an interface only contains the method headers (no implementation of methods and no attributes) where as a class contains both attributes, methods and method implementations.
Example
public interface IBankAcccount
{
double AccountBalance();
bool IsActive();
}
Note that we havent [...]
Archive for May, 2006
What is an Interface and how is it different from Abstract Classs?
Posted in OOPS on May 30, 2006 | 6 Comments »
What is an Abstract Class?
Posted in OOPS on May 30, 2006 | 4 Comments »
We usually think of classes as being complete definitions. However, there are situations where complete definitions of a class is not possible. In OO, we can create a class that have incomplete definitions ( we can define what methods should be there in the class, but not the definition of the method). These incompletly defined classes [...]
What is Polymorphism & How is it implemented?
Posted in OOPS on May 30, 2006 | 8 Comments »
Polymorphism refers to the ability of two or more objects belonging to different classes to resepond exactly to the same message in class specific ways.
Note : If you search the web for polymorphism, you will find many many definitions. I even read somewhere that overloading is also a kind of polymorphism. But a majority of the [...]
What are Collections?
Posted in OOPS on May 29, 2006 | 2 Comments »
A collection object is an object that can hold multiple references of some other type of objects. Different collections in OO
Array - In C# arrays are objects.
Ordered lists – similar to array. elements placed in a particular order and retrieved in same order
SortedList – similar to ordered list. The elements are sorted when added to [...]
What is Inheritance, Overriding,OverLoading ?
Posted in OOPS on May 29, 2006 | 5 Comments »
Inheritance is the process of creating a new class from one or more existing class. In otherwords, a new class acquires the qualities of existing class.
Example. Lets say that we need to model a bank account. Lets say that the bank has only two types of account – Savings Account and Current Account. Both of [...]
Are programmers blind?
Posted in Career on May 29, 2006 | Leave a Comment »
This is one of the stories which every one knows. Once a couple of blind men, in-order to understand an Elephant, went to a zoo. Each went and touched the Elephant and got a feel of it. They went back home and started to write about Elephant in their own experience. The blind man who [...]
What are associations, links and aggregations?
Posted in OOPS on May 29, 2006 | 4 Comments »
Association is the relationship between two classes. When the association is between two classes, its called Binary Association. When the association is between two instances of the same class, then its called reflexive or unary association.
Example : Binary Association : Employee works for Employee
Unary Association: A Employee supervises Employees
For a given association between object A [...]
What is an Instance constructor?
Posted in OOPS on May 29, 2006 | 2 Comments »
Instance Constructor is a speical type of method in a class which have the same name as a class that gets executed when a new instance (object) of a class is creaetd.
Student s = new Student();
In the above line, C# compiler actually calls the constructor of Student class to create an instance. The constructor allocates [...]
What are Accessors(Properties)? Whats the power of Encapsulation?
Posted in OOPS on May 29, 2006 | 1 Comment »
As discussed in the previous posts, attributes are the information we gather about an object. In real time projects, we often restrict the access to these attributes for variety of reasons. One such reasons is data security ( we are not going to get into details of this). These kinds of restrictions are called as Information [...]
What are methods,method headers, signatures, arguments, parameters etc., ?
Posted in OOPS on May 27, 2006 | 5 Comments »
In order to make use of the service provided by an object, one should know what object is capable of performing and how to request for the service. Lets say an Object A wanted to use the service of Object B, then Object A should know what service(s) Object B provides and also should talk in [...]