Java how to access superClass attribute

Java how to access superClass attribute

Use keyword super to access attribute of superClass(Parent Class)

/**
 * @author lautturi.com
 * Java example:
 */
import java.util.*;

class Animal {
	protected String type = "animal";
}

class Dog extends Animal {
	public String type = "mammal";

	public void printType() {
		System.out.println("I am a " + type);
		System.out.println("I am an " + super.type);
	}
}

public class Lautturi {

	public static void main(String[] args) {

		Dog dog1 = new Dog();
		dog1.printType();

	}
}
Source:w‮.ww‬lautturi.com

output:

I am a mammal
I am an animal
Created Time:2017-09-18 20:25:53  Author:lautturi