lohacali.blogg.se

Worksheet 17 linked list introduction list stack ans
Worksheet 17 linked list introduction list stack ans











Using inheritance, we have to write the functions only one time instead of three times as we have inherited the rest of the three classes from the base class (Vehicle). Look at the below diagram in which the three classes are inherited from vehicle class: If we create a class Vehicle and write these three functions in it and inherit the rest of the classes from the vehicle class, then we can simply avoid the duplication of data and increase re-usability. To avoid this type of situation, inheritance is used. This increases the chances of error and data redundancy.

Worksheet 17 linked list introduction list stack ans code#

You can clearly see that the above process results in duplication of the same code 3 times. If we create these classes avoiding inheritance then we have to write all of these functions in each of the three classes as shown below figure: The methods fuelAmount(), capacity(), applyBrakes() will be the same for all three classes. You need to create classes for Bus, Car, and Truck.

worksheet 17 linked list introduction list stack ans

The article is divided into the following subtopics:Ĭonsider a group of vehicles.

  • Super Class: The class whose properties are inherited by a subclass is called Base Class or Superclass.
  • worksheet 17 linked list introduction list stack ans

  • Sub Class: The class that inherits properties from another class is called Subclass or Derived Class.
  • The derived class is the specialized class for the base class. These new features in the derived class will not affect the base class. When we say derived class inherits the base class, it means, the derived class inherits all the properties of the base class, without changing the properties of base class and may add new features to its own. The derived class now is said to be inherited from the base class. The new class created is called “derived class” or “child class” and the existing class is known as the “base class” or “parent class”.

    worksheet 17 linked list introduction list stack ans

    Inheritance is a feature or a process in which, new classes are created from the existing classes. ISRO CS Syllabus for Scientist/Engineer Exam.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.











    Worksheet 17 linked list introduction list stack ans