# Sunday, February 12, 2017

When I worked in consulting, part of my job was to interview potential new hires. This often included a technical screening. Here are a few of the questions I would ask on Object Oriented Programming (OOP)

What is the difference between an object and a class?

An object is an instance of a class. A class is a template - or blueprint - that describes what an object based on it will look like and behave. Further, objects have a defined lifetime - they are created and eventually destroyed; not so with classes.

What is encapsulation?

Encapsulation is an OOP principle describing an object hiding its implementation details form the outside world.

What is inheritance?

Inheritance describes a class that is derived from another class or from an interface. The derived class (or child class) inherits the properties and methods of the parent class or interface from which it is derived.

What is polymorphism?

Polymorphism describes to objects that can accept the same message (e.g., the same method call with the same parameters) and respond differently, but appropriately to that message. For example, a Customer class and an Invoice class may each have a "Print" method. Calling the Customer's print method could print a report listing details about the current customer, whereas calling the Invoice's Print method might print a specific invoice.  Polymorphism can be accomplished by implementing the same interface in multiple classes.

What is the difference between a Class and an Interface?

Although each can serve as a templates for inherited classes, an Interface includes only the names and signatures of properties and methods, whereas a class also includes the implantation of each method and property.

Comments are closed.