OOPS IN .NET




Explain different properties of Object Oriented Systems.

An object oriented system revolves around a Class and objects. A class is used to describe characteristics of any entity of the real world. An object is a pattern of the class. An actual object created at runtime is called as an instance. A class, apart from characteristics has some functions to perform called as methods. For.e.g A class named “Food” has attributes like ‘price’, ‘quantity’. “Food” class has methods like Serve_food(), bill_food().  
               Objects in Object Oriented Systems interact through messages.  
               Inheritance:- The main class or the root class is called as a Base Class. Any class which is expected to have ALL properties of the base class along with its own is called as a Derived class. The process of deriving such a class is Derived class. For the “Food” class, a Derived class can be “Class Chinesefood”.  
               Abstraction:- Abstraction is creating models or classes of some broad concept. Abstraction can be achieved through Inheritance or even Composition.  
               Encapsulation:- Encapsulation is a collection of functions of a class and object. The “Food” class is an encapsulated form. It is achieved by specifying which class can use which members (private, public, protected) of an object.  
              Polymorphism:- Polymorphism means existing in different forms. Inheritance is an example of Polymorphism. A base class exists in different forms as derived classes. Operator overloading is an example of Polymorphism in which an operator can be applied in different situations.  



What is the relation between Classes and Objects?

Class is a group of items, attributes of some entity. Object is any specific item that may or may not be a part of the class. When a class is created, objects for those classes are created.
Example:-
We create a Class “Food”. This class has attributes like ‘price’, ‘quantity’. For this food class, we create objects like “Spaghetti”, “Pasta”. 




what is Abstract class?


An Abstract class is only used for inheritance. This means it acts as a base class for its derived classes. One cannot use it to create objects. When a class is declared as “Abstract”, it can only be inherited and not instantiated. MustInherit Keyword can be used to declare a class as abstract.
Abstract classes can also specify abstract members.


What is Dispose Method?

Dispose method belongs to IDisposable interface. It is used to free unmanaged resources like files, network connection etc. it manages and handles this by an instance of the class that implements this interface. Dispose methods must be called explicitly and hence the any object using IDisposable must also implement finalizer to free resources in situations wherein Dispose is not called. Multiple calls to dispose method must be ignored when called once. The objects disposable methods must be called in the order of containment.
 

No comments:

Post a Comment