Top 25 OPPS Interview Questions & Answers

 


Top 25 OPPS Interview Questions & Answers

What is OOPS?

OOPs is abbreviated as object-oriented programming system in which programs are considered a collection of objects is nothing but an instance of the class.

What is Basic concept of OOPs?

Following are the concept of OOPs:

·       Abstraction

·       Encapsulation

·       Inheritance

·       Polymorphism

What is Class?

A class is simply a representation of type of object. It is the blue print template that describes in the details of an object.

What is an object?

An object is an instance of a class. It has its own state, behavior, and identity

What is Encapsulation?

Encapsulation is the attribute of an object, and it contains all data which is hidden. That hidden data can be restricted to the member of the class levels are: Public, Protected, Private, Internal, and Protected Internal.

What is Polymorphism?

Polymorphism is nothing but assigning behavior or value in sub class to something that was already declared in the main class. Simply, Polymorphism takes more than one form.

What is Inheritance?

Inheritance is a concept where one class shares the structure and behavior defined in another class. If Inheritance applied to one class is called Single Inheritance, and if it depends on multiple classes, then is called multiple Inheritance.

What are manipulators ?

Manipulators are the function that can be used in Conjunction with the insertion (<<) and extraction (>>) operators on an object. Examples are endl & setw.

Explain the term Constructor?

A constructor is method used to initialize the state of an object, and it gets invoked at the time object creation.

Rules for constructor are:

·       Constructor name should be the same as the class name.

·       A constructor must have no return type.

Define Destructor?

A destructor is method which is automatically called when the object is made of scope or destroyed. Destructor name is also the same as the class name but with the tilde symbol before the same.

What is an Inline function?

An Inline function is a technique used by the compilers and instructors to insert complete body of the function wherever that function is used in the program source code.

What is a friend function?

A friend function is a friend of a class that is allowed to access to Public, Private or protected data in that same class. If the function is defined outside the class cannot access such information.

A friend can be declared anywhere in the class declaration, and it cannot be affected by access control keywords like public, private, or protected.

What is virtual function?

A virtual function is a member function of a class, and its functionally can be Overridden in its derived class. This can be implemented by using a keyword called virtual, and it can be given during function declaration.

A virtual function can be declared using a token (Virtual) in C++.It can be achieved in C/Python language by using function pointers or pointers to function.

What is function overloading?

Function overloading is a regular function. But it is assigned with multiple parameters. It allows the creation of several methods with the same name which differ from each other by the type of input a output of the function.

Void add(int &a, int &b);

Void add(double &a, double &b);

Void add(struct bob &a, struct &b)

What is operators overloading?

Operators overloading is a function where different operators are applied and depends on arguments.

Operators ,-,*can be used to pass through the function, and it has its own precedence to execute.

What is an abstract class?

An abstract class is a class which cannot be instantiated. Creation of an object is not possible with an abstract class, but it can be inherited.

An abstract class can contain only an Abstract class while other languages allow non-abstract method as well.

What is ternary operator?

The ternary operator is said to be an operator which takes three arguments.

Arguments and result are of different data types and it depends on the function. The function. The ternary operator is also called a conditional operator.

What is the use of finalize method?

Finalize method helps to perform cleanup operations on the resources which are not currently used. Finalize method is protected, and it is accessible only through this class by a derived class.

What is method overriding?

 Method overriding is a feature that allows a subclass to provide the implementation in the superclass by providing the same method name, same parameter, and same return type.

What is the super keyword?

The super keywords is used invoke the overridden method, which overrides one of its superclass methods. This keyword allows to access overridden methods and also to access hidden members of the superclass.

What is an interface?

An interface is a collection of an abstract method. If the class implements an interface, it thereby inherits al the abstract methods of an interface.

Java uses interface to implement multiple inheritances.

What are the different types of arguments?

A parameter is a variable used during the declaration of the function or subroutine, and arguments are passed to the function body, and it should match with parameter defined. There are two types of arguments:

         i.            Call by value: Value passed will get modified only inside the function, and it returns the same value whatever it is passed into the return.

       ii.            Call by reference: Valued passed will get modified in both inside and it returns the same or different value.

What is exception handling?

An exception is a event that occurs during the execution of a program. Exception can be of any type – Runtime exception, Error exceptions. Those exception are adequately handled through exception handling mechanism like try, catch and throw keywords.

What are tokens?

A compiler recognizes a token, and it cannot be broken down into components elements keywords, Identifiers, constants, string literals, and operators are example of tokens.

Even punctuation characters are also considered as tokens. Examples: Brackets, Commas, Braces, and Parenthese.

What is the difference between new and override?

The new modifier instructs the compiler to use the new implementation instead of the base class function. Whereas, override modifier helps to override the base class function.

 

 

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

Comments

Popular Posts