Java: Accessing member in parent class

This entry is part 41 of 54 in the series Learn Java

If your method overrides one of its parent class’s methods, you can invoke the overridden method through the use of the keyword super.

package javaapplication33;

public class Music {

    public class Rock {

        public void printout() {
            System.out.println("Printed in Rock Class.");

    public static class Metal extends Rock {

        // overrides printout in Superclass
        public void printout() {
            System.out.println("Printed in Metal Class");
    public static void main(String[] args) {
            Metal s = new Metal();




Series Navigation<< Java: Method Overiding
Java: Constructing a subclass >>

Leave a comment

Leave a Reply