Java examples for Object Oriented Design:Method Override
Override method from parent class
import java.util.*; public class Subclass extends Superclass { public boolean aVariable; //hides aVariable in Superclass public void aMethod() { //overrides aMethod in Superclass aVariable = false;//from w w w . j a v a2 s . co m super.aMethod(); System.out.format("%b%n", aVariable); System.out.format("%b%n", super.aVariable); } } class Superclass { public boolean aVariable; public void aMethod() { aVariable = true; } }