Object-Oriented Programming (OOP)

Q1. What is an example of dynamic binding?

Q2. For which case would the use of a static attribute be appropriate?

Q3. 1 Why would you create an abstract class, if it can have no real instances?

Q3. 2 Why would you create an abstract class, if it can have no real instances?

Q4. When does static binding happen?

Q5. What is the best reason to use a design pattern?

Q6. What is encapsulation?

Q7. What is an IS-A relationship?

Q8. 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?

Q9. Which code creates a new object from the Employee class?

Q10. Which type of constructor cannot have a return type?

Q11. 1 When is a constructor executed?

Q11. 2 When is a constructor executed?

Q12. If a local class is defined in a function, what is true for an object of that class?

Q13. Which two blocks are used to handle and check errors?

Q14. Why would you implement composition using an id instead of a reference?

Q15. Which statement best describes the method of inheritance in OOP?

Q16. Which type of inheritance ,when done continuously, is similar to a tree structure?

Q17. Which statement is true?

Q18. Which of the following is NOT an advantage of using getters and setters?

Q19. In context of OOP, what is association?

Q20. How are user stories different from use cases?

Q21. Which type of inheritance must be used so that the resultant is hybrid?

NOTE: Hybrid inheritance is a composition of multiple and hierarchical inheritances

Q22. A language that does not support polymorphism but supports classes is considered what?

Q23. Two classes combine private data members and provide public member functions to access and manipulate those data members. Where is abstraction used?

Q24. What are the five Creational Design patterns by the Gang of Four ?

Q25. In multilevel inheritance, one class inherits how many classes?

Q26. if an object is passed by reference, the changes made in the function are reflected _.

Q27. What is a method?

Q28. 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?

Q29. Which class has the highest degree of abstraction in a multilevel inheritance relationship of five levels?

Q30. Which is NOT one of the basic types of inheritance?

Q31. Why is code duplication so insidious?

Q32. When and how often is a static constructor called?

Q33. 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) {};

Q34. What is the purpose of static constructor?

Q35. What are CRC Cards?

reference link

Q36. 1 How are contents of a composition different from those of aggregation?

Q36. 2 Which statement about compositions and aggregations is true?

Q37. What is the result of using more abstraction?

Q38. Which is false for a member function of a class?

Q39. Why is inheritance used when creating a new class?

NOTE: I don’t have 4th variant in my test, it changed to new 5th variant. Is it also true?

Q40. In addition to attributes and behaviours, what quality must a class possess?

Q41. Which type of function among the following shows polymorphism?

Q42. Which words in the following list are candidates for objects: trumpet, clean, enrage, leaf, tree, collapse, active, and lively?

Q43. What best describes what object-oriented programming does?

Q44. Can abstract classes be used in multilevel inheritance?

Q45. What type of inheritance may lead to the diamond problem?

Q46. What is the relationship between abstraction and encapsulation?

Q47. Which of these keywords are access specifiers?

Q48. What is a reference to an object?

Q49. Why is unit testing harder in OOP than functional programming?

Q50. What is the function of a user diagram?

Q51. How do object behaviour and attributes differ?

Q52. The open/closed principle states that classes should be open for _ but closed for _.

Q53. Why would you override a method of a base class?

Q54. What is a copy constructor?

Q55. What defines the catch block most accurately?

Q56. 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?

Q57. 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?

Q58. _ describes an aggregation

Q59. Which type of function can be used for polymorphism?

Q60. Which choice is a benefit of using dependency injection?

Q61. Are you required to return an object if it was passed by reference to a function, and why or why not?

Q62. Why is inheritance?

Q63. What is the best example of a superclass and subclass relationship?

Q64. Which statements best describe the Gang of Four design patterns called Memento and Observer?

Q65. What does the value (0.5,0.5,0.5) indicate in the class diagram specification position: Coordinate = (0.5,0.5,0.5)?

Q66. What is the most accurate example of the Liskov substitution principle?

public class Car{
public class FlyingCars extends Car{
   public void fly(){}
public class Tesla FlyingCar{}
public class Honda Car{}
public class Car{
   public void fly(){}
public class Tesla extends Car{}
public class Honda extends Car{}
public class Car{
public void fly(){}
public class Tesla Car{}
public class Honda Car{}
public class Car{
public class FlyingCars extends Car{
   public void fly(){}
public class Tesla extends FlyingCar{}
public class Honda extends Car{}

reference link

Q67. What is the difference between a parameter and an argument?

Q68. What is the scope of a class nested inside another class?

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.

Q69. Methods and attributes that define an object are a kind of blueprint called what?

Q70. 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?

Q71. What is the main idea behind separation of concerns?

Q72. What is the purpose of the finally block?

Q73. Which choice is not an OOP language?

Q74. What is the function of a finalizer or destructor?

Q75. An instance of which type of class cannot be created?

Q76. In the context of OOP, what is composition?

Q77. Static polymorphism uses method _ ?

Q78. What does a concrete class not have?

Q79. How does dynamic typing complicate troubleshooting?

Q80. What is the difference between early binding and late binding?

Q81. What is the difference between an interface and an abstract class?

Q82. 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.

Q83. What are the four principles of object-oriented programming?