98-372 · Question #72
Which Object Oriented (OO) principle is used to deal with objects without the need to know what exact class they belong to?
The correct answer is B. Polymorphism. Polymorphism is the Object Oriented (OO) principle that is used to deal with objects without the need to know what exact class they belong to. This is an extension of the inheritance concept. In object-oriented programming, polymorphism is the ability to create variables…
Question
Which Object Oriented (OO) principle is used to deal with objects without the need to know what exact class they belong to?
Options
- AAbstraction
- BPolymorphism
- CClass
- DInheritance
How the community answered
(27 responses)- A7% (2)
- B74% (20)
- C4% (1)
- D15% (4)
Explanation
Polymorphism is the Object Oriented (OO) principle that is used to deal with objects without the need to know what exact class they belong to. This is an extension of the inheritance concept. 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 binding. Answer: C is incorrect. A class is a set of objects that share the same properties and behavior. It is the instinctive view of a kind of objects. Answer: A 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: D 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
Community Discussion
No community discussion yet for this question.