answersLogoWhite

0

What is the overridden in java?

User Avatar

Anonymous

13y ago
Updated: 8/20/2019

Any time you have a class that inherits a method from a superclass, you have the opportunity to override the method (unless, as you learned in the earlier chapters, the method is marked final). The key benefit of overriding is the ability to define behavior that's specific to a particular subclass type. The following example demonstrates a Porsche subclass of Car overriding the Car version of the drive() method:

public class Car {

public void drive() {

System.out.println("Generic Car Driving Generically");

}

}

class Porsche extends Car {

public void drive() {

System.out.println("Porsche driving Full Throttle");

}

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What method in Java cannot be overridden?

Methods which are declared final cannot be overridden.


Is it possible to override overloaded methods why?

Yes. Overloaded methods are also Java methods and all Java methods can be overridden.


Is systemoutprint is an object?

System.out.println() is a general output line used in Java. System.out are objects of the perdifined class java.lang Println is a method within this class. This method can however be overridden.


What is fix in java?

fixed method means is one which cannot be overridden by a subclass. A fixed method can be declared by prefixing the word-final before a method. We can use the keyword final to donate a constant.


How are vetoes overridden?

Vetoes are overridden by 2/3 vote from The House and Senate.


First president whose veto was overridden?

John Tyler was the first to have a veto overridden.


How do you prevent method overriding in java?

Use the word "final" directly preceding your method declaration. The presence of final keyword directs java to ensure that, this particular method would not be overridden by any of its child classes.


How is the precedence of operators in an expression overridden in most languages?

Precedence of operators in an expression overridden by the use of parentheses


Can an overridden method return void instead of an object?

Sure. An overridden method can return anything it wants.


Has the president ever been overridden by the congress?

I am not sure what you mean. Congress has overridden some presidential vetoes.


How can a presidents veto be overridden by congress?

A president's veto can be overridden by Congress with a 2/3 majority in the House. If it is a pocket veto though, the veto cannot be overridden.


What if a final keyword is applied to a function?

The final keyword in JAVA means that the class can no longer be derived, i.e. it cannot be used as a base class for a new child class.If you declare a method as final, this method cannot be overridden in any of the child class that may extend this class.