nerdexam
Microsoft

98-372 · Question #46

Which Object Oriented (OO) principle is used to hide the behavior of an object from its implementation?

The correct answer is C. Encapsulation. Encapsulation is the Object Oriented principle that is used to hide the behavior of an object from its implementation. It is used to separate what an object looks like from how it implements its Encapsulation refers to one of the two related but distinct notions or to the combina

Understanding Namespaces and Classes

Question

Which Object Oriented (OO) principle is used to hide the behavior of an object from its implementation?

Options

  • AInheritance
  • BPolymorphism
  • CEncapsulation
  • DAbstraction

How the community answered

(64 responses)
  • A
    14% (9)
  • B
    5% (3)
  • C
    72% (46)
  • D
    9% (6)

Explanation

Encapsulation is the Object Oriented principle that is used to hide the behavior of an object from its implementation. It is used to separate what an object looks like from how it implements its Encapsulation refers to one of the two related but distinct notions or to the combination thereof: A language mechanism to restrict access to some of the components of an object. A language construct that assists in bundling of data with the methods operating on that data. Many programming language experts use the first meaning alone, or combine it with the second meaning as a unique feature of OOP. However, other programming languages that provide closures view encapsulation as a feature of the language independent of object orientation. The second definition is based on the fact that in various OOP languages hiding of components is not automatic, and can be overridden. Therefore, those who support the second definition define information hiding as a detach notion . Answer: D is incorrect. Abstraction supports data hiding so that only the relevant data is exposed to the users and the remaining information remains hidden. It is the process where logic/program details are not accessible by the programmer. Instead of viewing things in detail, users are only shown an abstraction or just what is required to be communicated. This information comprises the module inputs and what is returned as outputs. Answer: B is incorrect. In object-oriented programming, polymorphism is the ability to create variables, functions, or objects having more than one form. The word polymorphism is derived from the Greek word meaning "having multiple forms". Polymorphism is used for implementing a programming technique called message-passing in which different types of objects define common interfaces for users' operations. Polymorphism is a feature that allows programmers to device methods that have the same name but different parameters. It simplifies the complexity of the program and provides an effective method of reusing modules. Polymorphism permits creation of two methods with the same name having different parameters. One version will accept two integer numbers and the other will accept two double numbers. The program will decide the method to be used at runtime based on the numbers entered; this feature is called dynamic Answer: A is incorrect. Inheritance is the technique to classify and reuse code by creating collections of attributes and behaviors called objects, that can be based on the earlier created objects. In traditional inheritance, classes define objects and they can inherit other classes. The new class called sub-class/derived class, inherits attributes and behaviors of the existing classes called super classes or ancestor classes. The inheritance relationship of a class gives rise to a hierarchy. Objects can be defined directly from other objects without defining classes in prototype-based programming. Inheritance is the ability of classes to inherit other classes and makes reuse of code possible. When a class file inherits from another class, it inherits all its members (variables and methods). Different languages use different terms to categorize the two parties in inheritance.

Topics

#encapsulation#OOP principles#abstraction#information hiding

Community Discussion

No community discussion yet for this question.

Full 98-372 Practice