Java Keyword - super

Java Keyword - super
‮efer‬r to:lautturi.com
/**
 * @author lautturi.com 
 * Java example: Java super Keyword Example
 */

import java.util.*;

class Animal { // Superclass (parent)
	public void display() {
		System.out.println("an animal");
	}
}

class Dog extends Animal { // Subclass (child)
	public void display() {
		super.display(); 
		// Call the superclass method
		System.out.println("a dog");
	}
}

public class Main {
	public static void main(String args[]) {
		// Create a Dog object
		Animal myDog = new Dog();
		// Call the method on the Dog object
		myDog.display();
	}
}
Created Time:2017-09-30 21:07:04  Author:lautturi