Question

In: Computer Science

OOP involves use of the following concepts: inheritance, polymorphism, and encapsulation. What are your definitions of...

  1. OOP involves use of the following concepts: inheritance, polymorphism, and encapsulation. What are your definitions of these terms? Why are they important? Does a program necessarily suffer if one or more of these items are absent?

Solutions

Expert Solution

Encapsulation can be defined as the mechanism which takes care of :

  • Binding the data with the functionalities that manipulates it.
  • It keeps the data and the code safe from external interference

Inheritance is the mechanism by which an object acquires the some/all properties of another object. For example, a child inherits some properties of parents. Hence, this is an example of inheritance.

Polymorphism means objects have different meanings based on their data type.

In other words it means that one method with multiple implementation, for a certain class of action. And which implementation to be used is decided at runtime depending upon the situation (i.e., data type of the object).

They are important because we can relate to real work applications using these concepts. With the help of encapsulation, we can  keep classes separated and prevent them from having tightly coupled with each other. Polymorphism allows us to have multiple methods with same signatures but with different functionalities. Inheritance provides reusability of code.

No, a program need not suffer if one or more of these items are absent.


Related Solutions

Which Feature of OOP illustrates code reusability? Abstraction, Encapsulation, Inheritance, Polymorphism or All of them.
Which Feature of OOP illustrates code reusability? Abstraction, Encapsulation, Inheritance, Polymorphism or All of them.
Inheritance - Polymorphism One advantage of using subclasses is the ability to use polymorphism. The idea...
Inheritance - Polymorphism One advantage of using subclasses is the ability to use polymorphism. The idea behind polymorphism is that several different types of objects can have the same methods, and be treated in the same way. For example, have a look at the code we’ve included for this problem. We’ve defined Shape as an abstract base class. It doesn’t provide any functionality by itself, but it does supply an interface (in the form of .area() and .vertices() methods) which...
Software Engineering Fundamentals: Classification (Grouping) Abstraction (Representing) Inheritance (Generalizing) Encapsulation (Modularizing) Association (Relating) Polymorphism (Executing) Understanding...
Software Engineering Fundamentals: Classification (Grouping) Abstraction (Representing) Inheritance (Generalizing) Encapsulation (Modularizing) Association (Relating) Polymorphism (Executing) Understanding and applying these fundamentals is crucial to great program design. Please describe, in your own words, any two out of the above 6 fundamentals. The answer must include practical examples (you are welcome to demonstrate your understanding by drawing a UML diagram, writing a small piece of pseudo-code, and/or writing a small piece of real code). Please describe each of the fundamentals you selected...
Write a simple short Java program of your choice which illustrates inheritance, polymorphism and the use...
Write a simple short Java program of your choice which illustrates inheritance, polymorphism and the use of interfaces. The program should not take up more than half a page of size A4.
This question demonstrates the use of inheritance and polymorphism. Design a Ship class that has the...
This question demonstrates the use of inheritance and polymorphism. Design a Ship class that has the following members: • A field for the name of the ship (a string). • A field for the year that the ship was built (a string). • A constructor and appropriate accessors and mutators. • A toString method that overrides the toString method in the Object class. The Ship class toString method should display the ship’s name and the year it was built. Design...
This question demonstrates the use of inheritance and polymorphism. Design a Ship class that has the...
This question demonstrates the use of inheritance and polymorphism. Design a Ship class that has the following members: • A field for the name of the ship (a string). • A field for the year that the ship was built (a string). • A constructor and appropriate accessors and mutators. • A toString method that overrides the toString method in the Object class. The Ship class toString method should display the ship’s name and the year it was built. Design...
Create a game of your choice that involves the following concepts:
C++ PROJECTCreate a game of your choice that involves the following concepts:STL library. (Maps, Sets, Lists, Stacks and Queues), with Iterators and AlgorithmsShow especially Especially Algorithm/Iterators/Containers in the STLMinimum of 750 linesInclude Full documentation
What is different between procedural and object-oriented programming? Match each of the following OOP concepts with...
What is different between procedural and object-oriented programming? Match each of the following OOP concepts with its example/description. Question 2 options: 12345678 Providing a way for an entity to behave in several ways OR providing multiple entities to be treated in a similar way 12345678 A key way of saving having to retype a lot of code for similar but different objects 12345678 The removal of non-essential information 12345678 Allowing which function to be called by an object to be...
Java assignment, abstract class, inheritance, and polymorphism. these are the following following classes: Animal (abstract) Has...
Java assignment, abstract class, inheritance, and polymorphism. these are the following following classes: Animal (abstract) Has a name property (string) Has a speech property (string) Has a constructor that takes two arguments, the name and the speech It has getSpeech() and setSpeech(speech) It has getName and setName(name) It has a method speak() that prints the name of the animal and the speech. o Example output: Tom says meow. Mouse Inherits the Animal class Has a constructor takes a name and...
Visual Studio C# Create an application illustrating the following: Class definition Encapsulation Constructor Instantiation Inheritance Suggestions:...
Visual Studio C# Create an application illustrating the following: Class definition Encapsulation Constructor Instantiation Inheritance Suggestions: Simulation Calculation Interface apps
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT