Online Tutorials & Training Materials | STechies.com
Register Login
Advertisement

OOPS Interview Questions and Answers

|| 1

OOPS Interview Questions and Answers
Stechies

What is OOPS?

Object Oriented Programming (OOPS) is the programming methodology that is based on real-world objects and their definitions. Concepts like polymorphism, abstraction, and encapsulation are part of OOPS methodology.

What are the principles of OOPs?

Principles of OOP's are

  • Inheritance
  • Polymorphism
  • Encapsulation. 
  • Inheritance

What are the advantages of OOPS concepts?

The advantages of OOPS are:

  • The programs written using the concept are easier to understand than Procedural programming.
  • The code can be reused as the programs are written through different classes.
  • The code can be protected through data abstraction that hides the private details that must not be altered.
  • Through polymorphism, classes with the same name can be used for different functions by altering the arguments and code inside them. OOPS provides greater flexibility while coding than many programming paradigms.
  • Code written in OOP can be tested easily.

What is Polymorphism in OOPs?

In polymorphism, two programs can have the same name, but different functionalities. They will be differentiated using the type and number of arguments during the function call.

For example, a method called Add() has no arguments. Another method Add(a,b) has two arguments a and b, which adds the two parameters passed on by the user. During method call, the type and number of arguments will decide which function will be executed.

What is Abstraction in OOPs?

Abstraction is the process of code protection that hides the private details that must not be altered. It hides the implementation details from the user by showing only necessary details.

What is Inheritance in OOPs?

Inheritance in OOPs is the concept through which a class inherits the properties of another class. Here, a child class can inherit the properties of the parent class. It can use the methods and fields of the parent class. Inheritance can be multiple, single, multilevel, hierarchical and hybrid.

What is encapsulation in OOPs?

The concept of encapsulation in OOPs allows the wrapping up of methods and variables together. It is achieved in OOP trough classes. It allows data abstraction and data hiding. Keywords like private, protected and public are used here to manage the data.

What is an interface in OOPs?

Interfaces in OOP define the functionality of a class without showing the implementation of that class. It is used to define a base class from which other classes can inherit properties. Objects cannot be created using an interface. In C++ and Java, interfaces are represented through abstract classes.

Can we instantiate a class within the implementation of other class?

Yes

What is Class in OOPs?

A class contains the properties defining the objects. An object is an instance of a class. Classes contain similar objects. For example, this code creates a class called student,

class student

{
                private ID;

                public name;

                public subject;

                public studentDetails(); 

}

What is object in OOPs?

An object in OOP is an instance of a class. It contains the methods and variables defined in the class. It is a prototype that defines the methods and properties of objects of a specific type. Or In other words, we can say Object is Instance of Class, By using Object we can access a class.

What is overloading in OOPs?

In function overloading, two functions can have the same name, but different methods and applications. They will be differentiated using the number of arguments and their data type during the function call.

For example, a method called Add() has no arguments. Another method Add(a,b) has two arguments a and b, having int data type, which adds the two parameters passed to it. During function call, the type and number of arguments will decide which function will be executed.

Similarly, operators are also overloaded in OOP.

What is difference between procedural & OOPs Programming?

The differences between OOP and Procedural programming are:

OOP

Procedural programming

The focus is on objects.

The focus is on structures.

Follows bottom-up approach.

Follows top-down approach.

The program is broken down into objects.

The program is broken down into sub units called functions.

There is provision for data hiding and security using access specifiers like private, public and protected.

No data security features here.

Inheritance allows classes to acquire the properties of other classes.

No inheritance in this paradigm.

What is the type of relation between item and bolt in OOPs?

The type of relationship between item and bolt in OOPs is generalization or inheritance.

What is inline function in OOPs?

Inline functions in OOPs are used to reduce function call overhead. The inline functions are expanded when they are called. The entire code of the function is substituted at the point of the method call, when the inline function is executed. This process can save the push or pop overhead in the stack.

What is data hiding in OOPs?

Data hiding in OOP is achieved using keywords like private, protected and public. It is used to protect the data properties from external alteration. The implementation details of the program are hidden from the other class members. The process helps to reduce complexity.

What is a deferred keyword?

Definition Differed means we are telling to the compiler The class has been declared inside of the Program.

What is modularity in OOPs?

Modularity is the process of breaking down a program into modules. It is related to encapsulation. It is a way of associating encapsulated abstractions to physical modules.

For example, in C++, a header file is created for the class interface. An implementation file is created representing the code of the class.

What is final class in OOPs?

The final class is a class which cannot be inherited by any other class. It cannot be a super-class, but can be a sub-class. Example,

final class Student1{

                code

}

What is static in OOPs?

The static keyword is used with variables, methods and classes. Static elements are assigned storage space only once in the lifetime of the program. The static keyword is used in this case.

What is association and aggregation in OOPs?

  • Association – This is the relationship between two classes that are represented through the objects. It can be one-to-one, one-to-many, many-to-one, many-to-many.
  • Aggregation – This is a form of association where there exists a HAS-A relationship between two classes. This is a one-way association.

What is constructor? What are types of constructors?

In OOP, a constructor is a function that gets executed during creation of an object. It has no return value and must have the same name as that of the class. It must have a public access modifier.

The types of constructor are:

  • Default constructor
  • Private constructor
  • Copy constructor
  • Parameterized constructor
  • Static constructor

What is Destructor?

In OOP, a destructor is a function that deletes an object. It gets called when the function and program stops executing. They have the same name as that of the class and have the ~ symbol before them. However, they don’t have any return type and do not take any arguments.

What is a friend function in OOPs?

The friend function of any class defined outside the class, but has access to all the private and protected members of the class.

Define Association and Dependency?

Association – This defines the relationship between two classes that can be depicted by their objects. The association can be one-to-one, one-to-many, many-to-one, many-to-many.

Dependency – This is a relationship between two objects where one object depends on the other for implementation. It can be also called a using relationship, where a class can depend on another class.

What Are Different Types Of Arguments in OOPs?

In OOP the arguments can be divided into two:

  • Default arguments – It is a value provided in the function, if the calling function does not have a value for the argument.
  • Constant arguments - These arguments are pre-defined and cannot be changed.

Define Exception Handlling?

Exception handling is the management of problems that arise during runtime. Exceptions are handled in OOP through the following ways:

  • throw – This is used to throw an exception if the program encounters a problem.
  • catch – This is used to catch an exception using an exception handler.
  • try – This identifies the code for which specific exceptions can be activated.

What is Method Overriding?

Method overriding allows a child class to work according to a particular implementation of a method that is present in the parent class. It is used for run time polymorphism. However, the method must have the same name and parameters in both classes.    

Other Important OOPs Interview Questions

  • How we can refer to a class without defining it?
  • Can we put non-declarative statement e.g. START-OF-SELECTION within a class?
  • What is static attribute & method?
  • How to create a global class ?
  • How can we pass importing parameter ? pass by value/pass by reference
  • Can we changed pass by reference in any method ?
  • What is preferred parameter ? more than one optional & no mandatory?
  • can we pass returing parameter by reference ? NO only pass by value?
  • can static method use instance attribute ?
  • Can a method call itself?
  • What is me variable?
  • What is constructor ?What are type of constructor ?When it is called?
  • Can we have export parameter in Instance constructor?
  • Can instance constructor raise exception ?
  • When static constructor is called?
  • Can we have interface for static class or constructor?
  • What is abstract class ?
  • Can we implement abstract method in abstract class ? if not then where it can be implemented?
  • What is final class & Method ?
  • Can subclass call super class constructor?
  • Can we call static constructor more than once in a program?
  • What is method redefinition?
  • What is interface ?
  • Can we implement interface in private section of any class ?
  • Is it mandatory to implement all the methods of interface ?
  • What is alias ? Instead of specifying full name of interface methods we can assign it a name which can directly trigger?
  • What is Friendship?
  • What is event handler method ?
  • Can we have more than one event handler method for same event?
  • Can event have import parameter ?
  • How you handled exception during programming?
  • What is cleanup section ?
  • What is BADI?
  • What is check box for multiple use in BADI?
  • How to search a BADI ?
  • What is Value table and Check table, Difference between them?
  • What are secondary index's?
  • What is the draw back of secondary index's?
  • What are conversion routines?
  • At which level are they mantained?
  • what are Predeifined data types?
  • Which predefined data type uses conversion routines?
  • When is difference btw native and open sql
  • Difference between Modify and Update
  • Which is more efficient for all entries or joins?
  • When is implicit commit triggered.
  • What are RFC?
  • How do u create a destination system?
  • What are different types of commits used?
  • What are search helps?
  • Types of tables?
  • Difference between pool tables and cluster tables?
  • What is a delivery class?
  • What are the types of delivery class?
  • Difference between System tables and control tables?
  • What is normalization?
  • What is BCNF?
  • What is persistant class?
     


Comments

  • 20 Apr 2012 10:48 am Best Answer
    1.Principles of OOp's is
    a. Inheritance
    b. Polymorphism
    c. Casting.
    3. Class is user defined data type which is used to declare Methods, Events, Attributes.
    3. Object is Instance of Class, By using Object we can access a class.
    4. Yes.
    5. Definition Differed means we are telling to the compiler The class has been declared inside of the Program.

Advertisement