ASP.NET,C#.NET,VB.NET,JQuery,JavaScript,Gridview,SQL Server,Ajax,jQuery Plugins,jQuery UI,SSRS,XML,HTML,jQuery demos,code snippet examples.

Breaking News

  1. Home
  2. OOPs
  3. OOP Interview Questions with Answers

OOP Interview Questions with Answers

OOP is the greatest programming structure. It help us to reuse same code in multiple place which reduce code redundancy. At present we can’t imagine software development without OOP.  Here is some common important questions and answers in OOP or Object Oriented Programming. Hope it will help you to build successful carrier.
What is OOP?
OOP or Object Oriented Programming is one kind of programming system where programs are considered as a collection of objects.  Object is an instance of a class.
What are the basic features of OOP?
Following are the basic concepts or features of OOP:
  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism
What is a Class?
A class is a representation of a type of object. It is the blueprint or plan or template that describes the details of an object.
What is an object?
Object is an instance of a class. It has its own state, behavior and identity.
What is the difference between an object and a class?
A class is a data type and an object is an instance of a class (that). Objects hold any information, but classes don’t have any information. Class can have sub-classes but an object doesn’t have sub-objects.
What are access modifiers?
  1. Public
  2. Private
  3. Protected
  4. Internal
  5. Protected internal
What is Abstraction?
Abstraction is a process of showing only the relevant and essential information to the users without showing unnecessary information.
What is Encapsulation?
Encapsulation is a process of protecting unwanted access of information. It is an attribute of an object.
What is Polymorphism?
Polymorphism is a process of allowing an entity to multiple forms.
What is Inheritance?
Inheritance is a process of re-usability of code. It eliminates the use of redundant code. In this system child class can obtained all the features of parent class. Parent class is called based class and the child class is called derived class.
What is the difference between abstraction and encapsulation?
Abstraction is the process to show only the relevant information’s. Encapsulation is the way to do this. Abstraction works on the OO design phase, while encapsulation works on development phase.
Abstraction is the class design. That means, how we will create our class tree, inheritance tree, which methods are general, which are privets, which are inherited, which will be overridden, which attributes are privet or protect, where to use an abstract class or interface.
We can also say, encapsulation is just one of many techniques that can be used to create an abstraction. In C#, there are lots of built in methods and we use them in different purpose. But we can’t see actual codes of those methods. For example consider the methods “Response.Write”. We can only use it but it is not possible the see the codes.
What is Constructor?
Constructor is a member function and its name is as like as class name. It is used to initialize the class object. Constructor & Destructor both are necessary for every class. If we don’t create them compiler automatically create them by himself. Constructor & Destructor has no return type. It is called when a class object is created. Constructor & Destructor has no statement primarily. But we can create custom statement. Constructor may have parameter or not.
What is Destructor?
Destructor is used to delete object instance from the memory. We need to destroy object instance after its task. If we don’t does this compiler automatically do this? Its name is as like class name. Only extra ~ sign is used before its name. It has no parameter and it doesn’t accept any operator.
What are the various types of constructors?
There are three types of constructors:
  1. Default Constructor – With no parameters.
  2. Parametric Constructor – With Parameters.
  3. Copy Constructor – This creates a new object as a copy of an existing object.
What are manipulators?
Manipulators are the functions which can be used in conjunction with the insertion (<<) and extraction (>>) operators on an object. Examples: endl, setw.
What is early and late binding?
Early binding (static binding) refers to assignment of values to variables during compile or design time whereas late binding (dynamic binding) refers to assignment of values to variables during run time
Example:
Over loading is early binding
Over ridding is late binding
What is ‘this’ pointer?
This pointer or this keyword refers to the current object of a class.
What are tokens?
It is recognized by a compiler and it cannot be broken down into component elements. Some example of token: Keywords, identifiers, constants etc.
Can you give some examples of tokens?
Some examples of token are: Keywords, Identifiers, Constants, Operators, Brackets, and Commas.
Difference between overloading and overriding?
Overloading
  1. It is static binding.
  2. It is a compile time polymorphism.
  3. At the compile time the compiler know which object is assigned for which class.
  4. Method name will be same, parameters will be different and its return type may or may not same.
  5. Example- operator overloading, function overloading.
Overriding
  1. It is dynamic binding.
  2. It is a run time polymorphism.
  3. At the compile time the compiler didn’t know which object is assigned for which class. Compiler knows it at run time.
  4. Method name will be same, parameters will be same and its return type will be same.
  5. Example- virtual function.
What is static binding?
  • It is a compile time polymorphism.
  • At the compile time the compiler know which object is assigned for which class.
  • Method name will be same, parameters will be different and its return type may or may not same.
  • Example: Overloading
What is dynamic binding?
  • It is a run time polymorphism.
  • At the compile time the compiler didn’t know which object is assigned for which class. Compiler knows it at run time.
  • Method name will be same, parameters will be same and its return type will be same.
  • Example: Overriding
What are base class, sub class and super class?
Base Class– the root class.
Sub class– a class that inherits from one or more base classes.
Super Class– the parent class from which another class inherits.
Is it possible to call the base method without creating an instance?
Yes, it is possible.
Create that method as Static

No comments