Ask Question

Consider a class called Rocket that has a private instance variable called Engine. You are writing a "getter" for the Engine. Using the guiding principles of data encapsulation, under what circumstances is it allowed to return a reference to the existing Engine?

+2
Answers (1)
  1. 16 January, 02:33
    0
    when user wants duplicate copy of the object

    Explanation:

    Encapsulation are one of the key foundations of object-oriented programming (OOP). It involves the bundling of data or information with the methods and various techniques which operate on that data.

    It can be used in hiding the true values or state of a structured data object that is in a class, preventing unauthorized parties' direct access to them.

    The circumstances that can be allowed in returning a reference to the existing Engine is when user wants duplicate copy of the object.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider a class called Rocket that has a private instance variable called Engine. You are writing a "getter" for the Engine. Using the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers