Technical Interview Questions OOPS | Viva Questions C++ | Part 1

1. What is OOPs?

Object oriented programming organizes a program around its data, i. e., objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code
2. What are the principle concepts of OOPS?
There are four principle concepts upon which object oriented design and programming rest.
They are:
• Abstraction
• Polymorphism
• Inheritance
• Encapsulation
(i.e. easily remembered as A-PIE).
3.What is Abstraction?
Abstraction refers to the act of representing essential features without including the background details or explanations.
4. What is Encapsulation?
Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate. It prevents other objects from directly altering or accessing the properties or methods of the encapsulated object.
5. What is the difference between abstraction and encapsulation?
• Abstraction focuses on the outside view of an object (i.e. the interface) Encapsulation (information hiding) prevents clients from seeing it’s inside view, where the behavior of the abstraction is implemented.
• Abstraction solves the problem in the design side while Encapsulation is the Implementation.
• Encapsulation is the deliverables of Abstraction. Encapsulation barely talks about grouping up your abstraction to suit the developer needs.
6. What is Inheritance?
• Inheritance is the process by which objects of one class acquire the properties of objects of another class.
• A class that is inherited is called a base class.
• The class that does the inheriting is called a derived class.
• Inheritance is done by using : <visibility mode> <base class name>
• The two most common reasons to use inheritance are:
o To promote code reuse
o To use polymorphism
7. What is Polymorphism?
Polymorphism is briefly described as "one interface, many implementations." Polymorphism is a characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.

8.How does C++ implement polymorphism?
(Inheritance, Overloading and Overriding are used to achieve Polymorphism). Polymorphism manifests itself in the form of multiple methods having the same name.
• In some cases, multiple methods have the same name, but different formal argument lists (overloaded methods).
• In other cases, multiple methods have the same name, same return type, and same formal argument list (overridden methods).
9. Explain the different forms of Polymorphism.
There are two types of polymorphism one is Compile time polymorphism and the other is run time polymorphism. Compile time polymorphism is method overloading. Runtime time polymorphism is done using inheritance and interface.
Note: distinct forms of polymorphism:
• Method overloading
• Method overriding through inheritance
10. What is method overloading?
Method Overloading means to have two or more methods with same name in the same class with different arguments. The benefit of method overloading is that it allows you to implement methods that support the same semantic operation but differ by argument number or type.
Note:
• Overloaded methods MUST change the argument list
• Overloaded methods CAN change the return type
• Overloaded methods CAN change the access modifier
• Overloaded methods CAN declare new or broader checked exceptions
• A method can be overloaded in the same class or in a subclass
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...
 
Posts RSSComments RSSBack to top
© 2013 Updated Tech News Results and Reviews