answersLogoWhite

0

When a class inherits from another class, it is implicitly given all the functions of its parent class. For example, if we have a class foo which has functions f1 and f2, and we write another class zed which inherits from class foo, we can call the function zed.f1 or zed.f2, without having to write them again. Effectively, the code for f1 and f2 are copied from foo into bar.

Overriding is when you want zed.f1 to do something other than what foo.f1 does. By re-writing f1 in zed, we change what it does in zed without changing what it does in foo.


This becomes important when we start talking about abstraction. In well-designed object-oriented languages, we can use child classes in place of their parents. For example, if we have yet another class bar that performs operations on a foo, we could give it a zed instead and it would still work, because zed must have all the functions that foo does.

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Computer Science

How does subtype polymorphism work in Java?

Subtype polymorphism in Java allows objects of a subclass to be treated as objects of their superclass. This means that a subclass can be used wherever its superclass is expected, allowing for more flexibility and reusability in code. This is achieved through inheritance and method overriding, where a subclass can provide its own implementation of methods defined in its superclass.


What are the advantages of multiple inheritance over single inheritance?

The advantages of multiple inheritance over single inheritance include being a realistic software model. It is useful in breaking down complicated behavior into sets of characteristics that does not interfere with one another.


When making hardware decisions the overriding considerations of a business should be technology cost and currency?

True


Advantages of frame based expert systems?

Frame-based systems support class inheritance, i.e. the process by which all characteristics of a class-frame are assumed by the instance-frame.


What are the key differences between a parent class and a grandparent class in object-oriented programming?

In object-oriented programming, a parent class is a class that is extended by another class, known as a child class. A grandparent class, on the other hand, is a class that is higher up in the inheritance hierarchy and is not directly extended by the child class. The key difference is that a parent class is directly related to the child class, while a grandparent class is further up the inheritance chain.

Related Questions

Is it possible to implement method overriding in each and every type of inheritance?

Yes. Method Overriding is not possible without inheritance and it can be done in all possible types of inheritance.


Is it possible to implement method overriding every type of inheritance?

yes if larry has a mustache


Is it possible to implement overriding in every inheritance?

Yes. It is possible to implement overriding in every inheritance level. If there are methods of the same name in multiple classes in the hierarchy the one that is closest to the current object gets invoked. The other methods can be specifically invoked using the super keyword.


Example of overriding in java?

For example: class Speak { void SayHello(){}; } class Boy extends Speak { void SayHello(){System.out.println("I'm a boy");} } So overriding is usual to rewrite the motheds in subclasses .In subclsses ,you can override the methods acceded from his parent class.


Why can't method override be used without inheritance?

Overriding a method means that you are replacing an existing or virtual method that has already been defined in the parent object class, so without using inheritance, there can be no existing method to override.


Make a sentence with the word overriding?

Your safety is our overriding consideration.


Difference between inheriting a method and overriding?

Inheriting a method means - a class is able to use a method that is declared in its parent class. Because of inheritance we need not re-declare the method in the child class again but still use it as it is. Overriding means re-declaring a method that is already available in the parent class in the child class to alter its features as per the requirement in the child class.


What is the advantages of overriding?

Overriding is a feature that is available while using Inheritance. It is used when a class that extends from another class wants to use most of the feature of the parent class and wants to implement specific functionality in certain cases. In such cases we can create methods with the same name and signature as in the parent class. This way the new method masks the parent method and would get invoked by default.


Is overriding a dynamic polymorphism in c plus plus or not?

In C++, overriding and function, method, or operator is a different thing than (dynamic) polymorphism, so overriding a polymorphic method is almost entirely possible.


What is the opposite of overriding?

The opposite of the gerund overriding would be approving or endorsing.(In the US Congress, the failure to override a veto is confirming it.)The adjective overriding (meaning of primary importance, overarching) has the opposites secondary, insignificant, negligible, or unimportant.


How can you end a veto?

by overriding the veto


What was first boycott was overriding on?

blacks