Loading, please wait...

A to Z Full Forms and Acronyms

OOPs interview Questions and Answers

Jun 24, 2021 OOPs, interview questions&answers, 4634 Views
Here you will find frequently asked OOPs questions and answers.

This article will help you to find basics Interview Questions and Answers for OOPs for beginners.

Q.1 How many pillars of OOPs are there? Name them.

Ans. There are four pillars of OOPs

  1. Encapsulation
  2. Inheritance
  3. Abstraction
  4. Polymorphism

Q.2 What is data abstraction?

Ans. Data abstraction refers to the process of representing essential features without including background details or explanations.

Q.3 What is encapsulation?

Ans. The wrapping of data and function into a single unit is called data encapsulation.

Data encapsulation enables data hiding and information hiding.

Q.4 What is inheritance?

Ans.

  1. Inheritance is the process by which one object can acquire and the use of properties of another object.
  2. The existing class is known as a base class or superclass.
  3. The new class is known as a derived class or subclass.
  4. The derived class shares some of the properties of the base class. Therefore a code from a base class can be reused by a derived class.

Q.5 What is the difference between compile-time and run-time polymorphism.

Ans.

Compile-time polymorphism:- In compile-time polymorphism, the call is resolved by compiler. Overloading is compiled time polymorphism where more than one methods share the same name with different parameter or signature and different return type.

Run time polymorphism:- In run time polymorphism, the call is not resolved by compiler. Run time polymorphism happens when you use method overriding.

Q.6 What are the data types? Name some.

Ans. A data type is a classification that specifies which type of value can be applied without causing an error in any program. There are some types of data types,

  • Integer

  • floating-point numbers

  • characters

  • strings

  • arrays

  • dates

  • boolean values and

  • varchar etc..

Q.7 What is the difference between public, protected, and private?

Ans. In the below details you'll get the differences:

Public:- public class means everyone is allowed to access.

Protected:- Protected class means that members of subclasses are also allowed to access.

Private:- Private class means that only members of the same class are allowed to access.

Q.8 What is an abstract class?

Ans. An abstract class is a class that contains at least one function in it. Abstract classes are used to provide an interface for its subclass classes.

Q.9 What is an interface?

Ans. An interface is a programming structure or syntax that allows the computer to enforce certain properties of an object (class).

Q.10 How many types of loops are there?

Ans.

while loop:- A while loop is the most straightforward looping structure.

while(condition)
{
// code/logic...
}

Do-while:- A do-while loop is similar to the while loop except that the condition is always executed after the body of a loop. It is also called an exit-controlled loop.

do
{
// code/logic...
}
while(condition)

For loop:- A for loop is a more efficient loop structure in ‘C’ programming.

for(initialize; condition; increment/decrement)
{
// code/logic...
}

//Like..

for(int i=0;i<count;i++)
{
// code/logic...
}

Q.11 What is an array?

Ans. An array is a collection of homogenous elements. The elements of the array share the same variable name but each element has its own unique index number.

Q.12 What is a format specifier?

Ans. Formate specifier is used during input and output. It is a way to tell the compiler what type of data is in a variable during taking input using scanf() or printing using printf(). Like %c, %d, etc.

Q.13 What is a pointer?

Ans. A pointer is used to holds the address of another variable. They have data type just like a variable, like an integer type pointer can hold the address of an integer variable and a character type pointer can hold the address of char variable.

Q.14 Difference between array and array list?

Ans.

Array:- (i) Array is a fixed-length data structure

(ii) we can not change the length of an array once created.

(iii) an array can contain both primitives and objects.

ArrayList:- (i) ArrayList is a variable-length collection class.

(ii) we can change the length of ArrayList.

(iii) we cannot store primitives in an ArrayList

Q.15 What is recursion?

Ans. When the function is called within the same function, it is known as recursion. This allows the function to be repeated several times since it calls itself during its execution.

 

A to Z Full Forms and Acronyms

Related Article