Interview Questions

Describe different concepts of oops in delphi ?

Delphi Interview Questions


(Continued from previous question...)

Describe different concepts of oops in delphi ?

OOP is a design philosophy. It stands for Object Oriented Programming. Object-Oriented Programming (OOP) uses a different set of programming languages than old procedural programming languages (C, Pascal, etc.). Everything in OOP is grouped as self sustainable "objects". Hence, you gain re-usability by means of four main object-oriented programming concepts.


oops in delphi
1. encapsulation is implemented with classes. data and methods declared together.
2. information hiding is achieved with private and protected sections. private is visible to the unit only, protected is visible to descendants only. public are visible to anyone.
3. inheritence is implemented with class inheritence. on class declaraton, you can specify the ancestor. the descendant will have all data and methods of the ancestor.
4. run-time polymorphism is implemented with virtual methods. virtual methods are late-binded, that is, in a heterogenious list, the appropriate method is called for every item, no matter if the type is unknown at compile-time.

please note, that delphi is defective in terms of OO, because it allows you to declare methods that are not behaving like they should (not marking them virtual). so consider any non-virtual methods as utility funtions that are final, that is, can not properly overriden. if you are not sure, mark all non-private methods virtual.

(Continued on next question...)

Other Interview Questions