68 382
Assignments Done
Successfully Done
In November 2018

Answer to Question #57481 in Java | JSP | JSF for Nancy Rodriguez

Question #57481
How do you override a method from another class?
Expert's answer
In Java, when a subclass contains a method that overrides a method of the superclass. Example:
class A {
public void message() {

public class B extends A {
public void message() {
Class A represents the superclass and implements a method call message(). The subclass called B inherits every method that could be in the A class. However, class B overrides the method message(), replacing its functionality from A.

A parking = new A();
parking.message(); // Prints "Hi"

A dates = new B(); // Polymorphism
dates.message(); // Prints "Hello"

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions