Top 50 + Object Oriented Programming (OOP) Skill MCQ

What is object-oriented programming?

Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.

OOP focuses on the objects that developers want to manipulate rather than the logic required to manipulate them. This approach to programming is well-suited for programs that are large, complex and actively updated or maintained. This includes programs for manufacturing and design, as well as mobile applications; for example, OOP can be used for manufacturing system simulation software.

The organization of an object-oriented program also makes the method beneficial to collaborative development, where projects are divided into groups. Additional benefits of OOP include code reusability, scalability and efficiency.

Mulitple Choice Questions of object-oriented programming for Freshers job interview prepration

Object-Oriented Programming (OOP)
Q1. What is an example of dynamic binding?
a. any method
b. method overloading
c. method overriding
d. compiling

Answer is method overriding

Q2. For which case would the use of a static attribute be appropriate?
a. the number of people in each house in a small neighborhood
b. the lot size for each house in a small neighborhood
c. the color of each house in a small neighborhood
d. the weather conditions for each house in a small neighborhood

Answer is the weather conditions for each house in a small neighborhood

Q3. 1 Why would you create an abstract class, if it can have no real instances?
a. to avoid redundant coding in children
b. to explore a hypothetical class
c. to prevent unwanted method implementation
d. to reserve memory for an unspecified class type

Answer is to avoid redundant coding in children

Q4. 2 Why would you create an abstract class, if it can have no real instances?
a. to have common behavior in derived classes
b. to explore a hypothetical class
c. to prevent unwanted method implementation
d. to reserve memory for an unspecified class type

Answer is to have common behavior in derived classes

Q5. When does static binding happen?
a. only when you export
b. both at compile time and runtime
c. at compile time
d. at runtime

Answer is at compile time

Q6. What is the best reason to use a design pattern?
a. It will result in code that is more extensible and maintainable
b. It will result in a more compact product.
c. It will speed initial development.
d. It will allow you to add that design pattern to your resume.
Answer is It will result in code that is more extensible and maintainable

Q7. What is encapsulation?
a. defining classes by focusing on what is important for a purpose
b. hiding the data and implementation details within a class
c. making all methods private
d. using words to define classes

Answer is hiding the data and implementation details within a class

Q8. What is an IS-A relationship?
a. It implies encapsulation.
b. A superclass object has an IS-A relationship with its subclass.
c. It implies a virtual method.
d. A subclass object has an IS-A relationship with its superclass or interface

Answer is A subclass object has an IS-A relationship with its superclass or interface

Q9. You want a method with behavior similar to a virtual method–it is meant to be overridden –expect that it does not have a method body. It just has a method signature. What kind of method should you use?
a. an abstract method
b. a public internal method
c. an internal method
d. a protected internal method

Answer is an abstract method

Q10. Which code creates a new object from the Employee class?
a. Employee currentEmployee = Employee.Create();
b. Employee currentEmployee = new Employee();
c. Employee currentEmployee;
d. Employee currentEmployee = Employee.New();

Answer is Employee currentEmployee = new Employee();

Q11. Which type of constructor cannot have a return type?
a. default
b. copy
c. parameterized
d. Constructors do not have a return type

Answer is Constructors do not have a return type

Q12. When is a constructor executed?
a. when an object is created from a class using the new keyword
b. when an class is defined using the class keyword
c. every time an object is referenced
d. when an object is created from a class using the create keyword

Answer is when an object is created from a class using the new keyword

Q13. 2 When is a constructor executed?
a. when an object is created from a class
b. when an class is defined using the class keyword
c. every time an object is referenced
d. when an object is created from a class using the create keyword

Answer is when an object is created from a class

Q14. If a local class is defined in a function, what is true for an object of that class?
a. The object can be accessed, declared, and used locally in that function.
b. The object must be declared inside any other function.
c. The object is temporarily accessible outside the function.
d. The object can call all the other class members anywhere in the program.

Answer is The object can be accessed, declared, and used locally in that function.

Q15. Which two blocks are used to handle and check errors?
a. do and check
b. catching and trying
c. try and catch
d. do and while

Answer is try and catch

Q16. Why would you implement composition using an id instead of a reference?
a. It makes it easier to save the entity.
b. all of these answers
c. It can make the entity retrieval more efficient
d. It minimizes coupling.

Answer is all of these answers

Q17. Which statement best describes the method of inheritance in OOP?
a. Inheritance describes the ability to create new classes based on an existing class.
b. Inheritance means that a group of related properties, methods, and other members are treated as a single unit or object.
c. Inheritance forces a class to have a single responsibility from only one parent.
d. Inheritance means that you will never have multiple classes that can be used interchangeably, even though each class implements the same properties or methods in different ways.

Answer is :- Inheritance describes the ability to create new classes based on an existing class.

Q18. Which type of inheritance ,when done continuously, is similar to a tree structure?
a. multilevel
b. hierarchical and multiple
c. hierarchical
d. multiple

Answer is hierarchical

Q19. Which statement is true?

  1. A default parameter’s constructor is not equivalent to the default constructor
  2. A default constructor is inherited from a parent class
  3. A default constructor can be called explicitly
  4. A default constructor cannot be defined by the coder

Answer is A default parameter’s constructor is not equivalent to the default constructor

Q20. Which of the following is NOT an advantage of using getters and setters?
a. Getters and setters can speed up compilation.
b. Getters and setters provide encapsulation of behavior.
c. Getters and setters provide a debugging point for when a property changes at runtime.
d. Getters and setters permit different access levels.

Answer is Getters and setters can speed up compilation.

Q21. In context of OOP, what is association?
a. Association is a relationship where all objects have their own life cycle and there is no owner.
b. Association is the process where model elements cooperate to provide higher-level behavior.
c. Association is whole/part relationship where one object is composed of one or more other objects, each of which is considered a part of the whole.
d. Association is where all objects have their own life cycle, but there is ownership, and child objects can not belong to another parent object.

Answer is Association is a relationship where all objects have their own life cycle and there is no owner.

Q22. How are user stories different from use cases?
a. User Stories are shorter and less detailed.
b. User stories are more accurate.
c. User stories are more detailed and structured.
d. User stories are more anecdotal and personal.

Answer is User Stories are shorter and less detailed.

Q23. Which type of inheritance must be used so that the resultant is hybrid?
a. multiple
b. any type of inheritance
c. multilevel
d. hierarchical

Answer is multiple

Q24. A language that does not support polymorphism but supports classes is considered what?
a. an object-based language
b. a class-based language
c. a procedure-oriented language
d. if classes are supported, polymorphism will be supported

Answer is an object-based language

Q25. Two classes combine private data members and provide public member functions to access and manipulate those data members. Where is abstraction used?
a. Abstraction is using a private access specifier for the data members.
b. Abstraction is using public member functions to access and manipulate the data members.
c. Abstraction is using the class concept with both data members and member functions.
d. There is insufficient information to decide where abstraction is being used.

Answer is Abstraction is using public member functions to access and manipulate the data members.

Q26. What are the five Creational Design patterns by the Gang of Four ?
a. Observer, State, Strategy, Template Method, and Visitor.
b. Composite, Visitor, State, Prototype, and Singleton.
c. Composite, Builder, Factory Method, Prototype, and Singleton.
d. Abstract Factory, Builder, Factory Method, Prototype, and Singleton.

Answer is Abstract Factory, Builder, Factory Method, Prototype, and Singleton.

Q27. In multilevel inheritance, one class inherits how many classes?
a. one class only
b. two classes
c. as many classes as required
d. at least two classes

Answer is one class only

Q28. if an object is passed by reference, the changes made in the function are reflected _.
a. to the main object of the caller function, too
b. on the caller function object and also the called function object
c. on the copy of the object that is made during the pass
d. only in the local scope of the called function

Answer is to the main object of the caller function, too

Q29. What is a method?
a. a set of instructions designed to perform a frequently used operation within a program and return no values
b. the exact same thing as a function and subroutine
c. a set of variables that can change over time
d. a procedure associated with data and behavior

Answer is the exact same thing as a function and subroutine

Q30. A mobile phone is made up of components such as a motherboard, camera, and sensors. The motherboard represents all the functions of a phone, the display shows the display only, and the phone is represented as a whole. Which of the following has the highest level of abstraction?
a. camera
b. display
c. motherboard
d. mobile phone

Answer is mobile phone

Q31. Which class has the highest degree of abstraction in a multilevel inheritance relationship of five levels?
a. the class at the third level
b. the class at the first level
c. All have the same degree of abstraction.
d. the class at the second level

Answer is the class at the first level

Q32. Which is NOT one of the basic types of inheritance?
a. multilevel inheritance
b. double inheritance
c. single inheritance
d. hierarchical inheritance

Correct answer is :- double inheritance

Q33. Why is code duplication so insidious?
a. The duplication uses unnecessary space.
b. One has to maintain all the duplicates.
c. Duplication can cause intellectual property concerns.
d. Duplication is easy to hide.

Answer is:- One has to maintain all the duplicates.

Q34. When and how often is a static constructor called?
a. It is called initially when an object is created and called with every new object instance.
b. It is called when an object is destroyed and only one time.
c. It is called initially when an object is created and only one time.
d. It is created at time when the object is discarded.

Answer is:- It is called initially when an object is created and only one time.

Q35. What does the code shown below demonstrate, and why?
static void Multiply(int num1, int num2) {};
static void Multiply(double num1, double num2, double num3) {};
static void Multiply(float num1, float num2) {};
a. polymorphism, because each method can perform different task
b. method overriding, because it display the same method name, different or same parameters, and same return type
c. method overloading, because it allows the creation of several methods with the same name, which differ by the type of input via parameter
d. method overriding, because it display the same method name, different parameters, and same return type

Answer :- method overloading, because it allows the creation of several methods with the same name, which differ by the type of input via parameter

Q36. What is the purpose of static constructor?
a. to initialize all the members with static value
b. to delete the static members when not required
c. to initialize the static members of class
d. to clear all the static members’ initialized values

Correct answer is:- to initialize all the members with static value

Q37. What are CRC Cards?
a. Code Responsibility Collection cards are a brainstorming tool used in the design of procedural software
b. Class Responsibility collaboration cards are a brainstorming tool used in the design of oop software
c. Code Responsibility Correction cards are tools used for debugging
d. Code Responsibility Correction cards are tools for modeling

Correct answer is:- Class Responsibility collaboration cards are a brainstorming tool used in the design of oop software

Q38. 1 How are contents of a composition different from those of aggregation?
a. if one element of an aggregation is dereferenced, all its elements are eligible for garbage collection
b. if a composition dies, the contents die
c. the contents of a composition are all siblings
d. an aggregation contains only abstract classes

Answer is: if a composition dies, the contents die

Q39. 2 Which statement about compositions and aggregations is true?
a. if one element of an aggregation is dereferenced, all its elements are eligible for garbage collection
b. if a composition dies, the contents die
c. the contents of a composition are all siblings
d. an aggregation contains only abstract classes

Correct answer is :- if a composition dies, the contents die

Q40. What is the result of using more abstraction?
a. it can increase code vulnerability
b. it can make code unsafe
c. it can limit code readability
d. it can be safer for coding

Correct answer is:- it can limit code readability

Q41. Which is false for a member function of a class?
a. Member functions can be defined only inside or outside the class body.
b. Member functions can be made to be friends of another class.
c. Member functions do not need to be declared inside the class definition.
d. All member functions need to be defined.

Correct answer is :- Member functions do not need to be declared inside the class definition.

Q42. Why is inheritance used when creating a new class?
a. to protect attributes from unwanted changes
b. to delegate coding responsibility more efficiently
c. to conserve memory
d. to avoid writing duplicate code
e. to separate class behavior from the more general

Answer :- to avoid writing duplicate code
to separate class behavior from the more general
NOTE: I don’t have 4th variant in my test, it changed to new 5th variant. Is it also true?

Q43. In addition to attributes and behaviors, what quality must a class possess?
a. a name
b. a state
c. a color
d. an object

Correct answer is :- a name

Click here to read more Technical Q&A

Q44. Which type of function among the following shows polymorphism?
a. inline function
b. undefined function
c. virtual function
d. class member function

Correct answer is virtual function

Q45. Which words in the following list are candidates for objects: trumpet, clean, enrage, leaf, tree, collapse, active, and lively?
a. leaf and tree
b. clean, enrage, and collapse
c. clean, active, and lively
d. leaf, tree, and trumpet

Correct answer is leaf, tree, and trumpet

Q46. What best describes what object-oriented programming does?
a. It focuses on objects that interact cleanly with one another.
b. It programs exclusively to interfaces.
c. It programs exclusively to classes.
d. It creates one class for all business logic.

Correct answer is:- It focuses on objects that interact cleanly with one another.

Q47. Can abstract classes be used in multilevel inheritance?
a. No, abstract classes can be used only in single-level inheritance since they must be immediately implemented.
b. yes, always
c. yes, but with only one abstract class
d. No, abstract classes do not have constructors.

Correct answer is yes, always

Q48. What type of inheritance may lead to the diamond problem?
a. single level
b. multilevel
c. hierarchical
d. multiple

Correct answer is multiple

Q49. What is the relationship between abstraction and encapsulation?
a. Abstraction is about making relevant information visible, while encapsulation enables a programmer to implement the desired level of abstraction.
b. Abstraction and encapsulation are essentially the same.
c. Abstraction and encapsulation are unrelated.
d. Encapsulation is about making relevant information visible, while abstraction enables a programmer to implement the desired level of encapsulation.

Correct answer is:- Abstraction is about making relevant information visible, while encapsulation enables a programmer to implement the desired level of abstraction.

Q50. Which of these keywords are access specifiers?
a. abstract and public
b. public and private
c. this and final
d. final and abstract

Correct answer is public and private

Q51. What is a reference to an object?
a. It is the address of variable only — not the method of an object.
b. It is a shallow pointer that contains address of an object.
c. It is the physical address of an object.
d. It is the address where the variables and methods of an object are stored.

Correct answer is:- It is the address where the variables and methods of an object are stored.

Q52. Why is unit testing harder in OOP than functional programming?
a. Objects may maintain internal state, which is not easily accessible by the tests.
b. The quality of unit testing frameworks for functional languages is better.
c. OOP promotes code reuse, which means that your tests have to consider more use cases.
d. Object-oriented languages tend to rely on frameworks such as Spring or Hibernate, which make them difficult to test.

Correct answer is:- Objects may maintain internal state, which is not easily accessible by the tests.

Q53. What is the function of a user diagram?
a. It connects actors to use cases.
b. It links actors to roles played in all use cases.
c. It lists all actors for each use case.
d. It minimizes the number of actors required.

Correct answer is :- It links actors to roles played in all use cases.

Q54. How do object behavior and attributes differ?
a. Behavior describe dynamic properties; attributes are static.
b. Attributes describe a state; behaviors describe a change.
c. Attributes apply only to a specified object; behavior apply to other linked objects.
d. Behaviors are vector quantities; attributes are scalars.

Correct answer is:- Attributes describe a state; behaviors describe a change.

Q55. The open/closed principle states that classes should be open for _ but closed for _.
a. refactoring; duplication
b. modification; duplication
c. extension; modification
d. reuse; encapsulation

Correct answer is: – extension; modification

Q56. Why would you override a method of a base class?
a. to define a method that must be implemented in a derived class
b. to define a custom implementation of an inherited member
c. to define a method that must be implemented in a superclass only
d. to define a class that can be inherited from

Correct answer is to define a custom implementation of an inherited member

Q57. What is a copy constructor?
a. It is a unique constructor for creating a new object as a copy of an object that already exists. There will always be only one copy constructor that can be either defined by the user or the system.
b.. It is a constructor that duplicates itself when requested on demand.
c. It is a common constructor for preventing the creation of a new object as a copy of an object that already exists. There will always be multiple standard constructors that can be either defined by the user or the system.
d. It is a constructor that duplicates itself on its own, based on memory available.

Correct answer is :- It is a unique constructor for creating a new object as a copy of an object that already exists. There will always be only one copy constructor that can be either defined by the user or the system.

Q58. What defines the catch block most accurately?
a. The catch block that will be executed is the one that best matches the type of exception thrown.
b. Multiple catch blocks can never be associated with a single try block.
c. Multiple catch blocks are mandatory for each try block.
d. Multiple catch blocks will all be executed in the case of an exception.

Correct answer is:- The catch block that will be executed is the one that best matches the type of exception thrown.

Q59. There are five classes. Class E is derived from class D, D from C, C from B, and B from A. Which class constructor(s) will be called first if the object of E or D is created?
a. A
b. B
c. C
d. C and B

Correct answer is A

Q60. You have modules that are dependent on each other. If you change one module, you have to make changes in the dependent modules. What term is used to describe this problem, and what is a potential solution?
a. Cohesion. A solution is to show that each module has certain responsibilities and to use an anticohesive design pattern.
b. Encapsulation. A solution is to implement one of the SOLID principles to ensure the modules do not encapsulate with each other.
c. Coupling. A solution is to refactor the code to be loosely coupled by using inversion of control and dependency injection.
d. Dependency. A solution is to implement polymorphism and abstraction to change and extract dependent elements of a module so that it functions on its own.

Correct answer is Coupling. A solution is to refactor the code to be loosely coupled by using inversion of control and dependency injection.

Q61. _ describes an aggregation
a. A class of resources
b. A group of methods
c. A collection of objects
d. A list of children

Correct answer is A collection of objects

Q62. Which type of function can be used for polymorphism?
a. virtual function
b. inline function
c. undefined function
d. private function

Correct answer is virtual function

Q63. Which choice is a benefit of using dependency injection?
a. loose coupling
b. code reusability
c. lazy initialization
d. data abstraction

Correct answer is :- loose coupling

Q64. Are you required to return an object if it was passed by reference to a function, and why or why not?
a. Yes, the caller function needs to reflect the changes.
b. No, you should use a global variable instead.
c. No, changes will be automatically reflected in the calling function.
d. Yes, the object must be the same in the caller function.

Correct answer is : – No, changes will be automatically reflected in the calling function.

Q65. What is inheritance?
Answer: – Inheritance is one of the core concepts of object-oriented programming (OOP) languages. It is a mechanism where you can to derive a class from another class for a hierarchy of classes that share a set of attributes and methods.

You can use it to declare different kinds of exceptions, add custom logic to existing frameworks, and even map your domain model to a database.

Q66. What is the best example of a superclass and subclass relationship?
a. car:toyota
b. ducks:pond
c. toes:feet
d. rock:stone

Correct answer is: – car:toyota

Q67. Which statements best describe the Gang of Four design patterns called Memento and Observer?
a. Memento notifies multiple classes of changes. Observer captures and restores an object’s internal state.
b. Memento defers the exact steps of an algorithm to a subclass. Observer defines a new operation to a class without change.
c. Memento alters an object’s behavior when its state changes. Observer encapsulates an algorithm inside a class.
d. Memento captures and restores an object’s internal state. Observer notifies multiple classes of changes.

Correct answer is :- Memento captures and restores an object’s internal state. Observer notifies multiple classes of changes.

Q68. What does the value (0.5,0.5,0.5) indicate in the class diagram specification position: Coordinate = (0.5,0.5,0.5)?
a. a default value of the Coordinate attribute
b. the size of the position array
c. an increment of the position attribute value
d. a default value of the position attribute

Correct answer is :- a default value of the position attribute

Q69. What is the most accurate example of the Liskov substitution principle?
A.
public class Car{
}
public class FlyingCars extends Car{
public void fly(){}
}
public class Tesla FlyingCar{}
public class Honda Car{}
B.
public class Car{
public void fly(){}
}
public class Tesla extends Car{}
public class Honda extends Car{}
C.
public class Car{
public void fly(){}
}
public class Tesla Car{}
public class Honda Car{}
D.
public class Car{
}
public class FlyingCars extends Car{
public void fly(){}
}
public class Tesla extends FlyingCar{}
public class Honda extends Car{}

Correct answer is : – D
public class Car{
}
public class FlyingCars extends Car{
public void fly(){}
}
public class Tesla extends FlyingCar{}
public class Honda extends Car{}
Q70. What is the difference between a parameter and an argument?
a. An argument can have many values while a parameter can have only one value.
b. An argument is the variable used for input values in a method. A parameter is the specific input value passed to the method.
c. A parameter is a variable in the declaration of a function. An argument is the value of this variable that gets passed to the function.
d. Parameters and arguments are the same

Correct answer is: – A parameter is a variable in the declaration of a function. An argument is the value of this variable that gets passed to the function.

Q71. What is the scope of a class nested inside another class?
a. Protected scope
b. Private scope
c. Global scope
d. Depends on access specifier and inheritance used

Correct answer is : – Depends on access specifier and inheritance used

Explanation: It depends on the access specifier and the type of inheritance used with the class, because if the class is inherited then the nested class can be used by subclass too, provided it’s not of private type.

Q72. Methods and attributes that define an object are a kind of blueprint called what?
a. a collection
b. a variable
c. a class
d. a procedure

Correct answer is : – a class

Q73. Assume single inheritance is used with classes A and B while A is the base class. Then assume classes C, D, and E, where C is a base class and D is derived from C, then E is derived from D. Class C is made to inherit from class B. Which type of inheritance is reflected?
a. Multilevel
b. Hybrid
c. Single level
d. Multiple

Correct answer is :- Multilevel

Q74. What is the main idea behind separation of concerns?
a. All of these answers
b. Applications are decomposed into parts
c. Parts are defined with minimal overlap
d. Each part is responsible for a separate concern

Correct answer is : – All of these answers

Q75. What is the purpose of the finally block?
a. To always run the finally block of code when the try block exits
b. To run code when an exception has not occurred
c. To run the block if an exception occurred
d. To run code whenever garbage collection requires it

Correct answer is : – To always run the finally block of code when the try block exits

Q76. Which choice is not an OOP language?
a. C#
b. Java
c. C
d. Python

Correct answer is : – C

Q77. What is the function of a finalizer or destructor?
a. To relinquish resources that are no longer needed
b. To delete a variable name
c. To reset an attribute value
d. To hold space, even after an object is no longer being used

Correct answer is : – To relinquish resources that are no longer needed

Q78. An instance of which type of class cannot be created?
a. Protected class
b. Base class
c. Anonymous class
d. Abstract class

Correct answer is : – Abstract class

Q79. In the context of OOP, what is composition?
a. Composition is the act of one object passing to another object an operation to be performed on behalf of the initial object.
b. Composition is a part/hole relationship where an object is composed of one or more other objects, each of which is considered a part of the whole.
c. Composition is a binding where the class/name association is not made until the object designated by the name is created at execution time
d. Composition is a process of collecting classes that provide a set of services for a particular domain

Correct answer is : – Composition is a part/hole relationship where an object is composed of one or more other objects, each of which is considered a part of the whole.

Q80. Static polymorphism uses method _ ?
a. overloading
b. inheritance
c. abstraction
d. overriding

Correct answer is : – overloading

Q81. What does a concrete class not have?
a. parents
b. pure virtual functions
c. attributes
d. purposes

Correct answer is :- pure virtual functions

Q82. How does dynamic typing complicate troubleshooting?
a. It can be difficult to identify variables that are incorrectly typed
b. The dynamic variables can assume only limited values
c. Storage is fixed for dynamic variables
d. Static variables are more flexible than dynamic variables

Correct answer is : – It can be difficult to identify variables that are incorrectly typed

Q83. What is the difference between early binding and late binding?
a. Early binding is when a variable is assigned a value when a scope is created. Late binding is when a variable is assigned a value after a scope is exited
b. Early binding is when a variable is assigned a value when the program starts. Late binding is when a variable is assigned after the program is running
c. There is no difference. In both cases, variables are assigned values when a program has completed startup and is running
d. Early binding is when a variable is assigned its value at compile time. Late binding is when a variable is assigned a value at run time

Correct answer is :- Early binding is when a variable is assigned its value at compile time. Late binding is when a variable is assigned a value at run time

Q84. What is the difference between an interface and an abstract class?
a. Interfaces can contain code or data. Abstract classes do not contain code or data. A class can inherit from more than one abstract class but can only implement one interface
b. Interfaces can contain code or data. Abstract classes do not contain code or data. A class can inherit from only one abstract class but can implement an unlimited number of interface
c. Abstract classes can contain code or data. Interface do not contain code or data. A class can inherit from only one abstract class but can implement an unlimited number of interfaces
d. Abstract classes can contain code or data. Interface do not contain code or data. A class can inherit from more than one abstract class but can only implement one interface

Correct answer is Abstract classes can contain code or data. Interface do not contain code or data. A class can inherit from only one abstract class but can implement an unlimited number of interfaces

Q85. What parameters are required to be passed to a class constructor?
Here they haven’t mentioned any specific language so let’s consider all languages.

a. reference to subclass // References to subclass are never required as you can simply Initialize subclass & use their object.
b. reference to base class // References to the base class are not required in Java, JavaScript & Python
c. reference to this pointer // While Python & JavaScript may require passing this or self in the constructor, It is not passed in Java constructor.
d. none

Correct answer is None

Q86. What are the four principles of object-oriented programming?
a. manipulation, encapsulation, inheritance, and dependency inversion
b. dependency inversion, open/closed principle, encapsulation, and inheritance
c. interface segregation, abstraction, dependency inversion, and inheritance
d. abstraction, encapsulation, inheritance, and polymorphism

Correct answer is :- abstraction, encapsulation, inheritance, and polymorphism

Q87. From the SOLID principles of object-oriented programming, which statement best describes the Liskov substitution principle?
a. A class should have only a single responsibility—that is, only changes to one part of the software’s specification should be able to affect the specification of the class.
b. Software entities should be open for extension, but closed for modification.
c. Many client-specific interfaces are better than one general-purpose interface.
d. objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

Correct answer is :- objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

Click here to read more Blogs

Click here to read more C++ interview Questions and Answers

About Author


After years of Technical Work, I feel like an expert when it comes to Develop wordpress website. Check out How to Create a Wordpress Website in 5 Mins, and Earn Money Online Follow me on Facebook for all the latest updates.

Leave a Comment