Skip to main content

Posts

Showing posts with the label OOP Concepts

Is It Possible To Define All The Methods In An Abstract Class?

It is possible create an abstract class with all concrete methods. But this class can’t be instantiated. Since it is an abstract class.    We may have situations where we don’t want to instantiate a class which is the base class for all the classes in the system or application. This base class may have lot of methods used for different modules in the application and we do not want to instantiate the object of the base class and want to use only the reference of the class.   An abstract class without any abstract methods should be a rare thing and you should always question your application design if this case arises. Normally you should refactor to use a concrete super class in this scenario.   One specific case where abstract class may justifiably have no abstract methods is where it partially implements an interface, with the intention that its subclasses must complete the interface.

What Is The Advantage of OOP?

You will get varying answers to this question depending on whom you ask. Major advantages of OOP are: Simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear; Modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system; Modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods; Extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones; Maintainability: objects can be maintained separately, making locating and fixing problems easier; Re-usability: objects can be reused in diffe...