1. Technology



Woman using laptop on patio
Jetta Productions/Blend Images/Getty Images

The super keyword enables a subclass to call the methods and fields of its superclass. It is not an instance of the superclass object but a way to tell the compiler which methods or fields to reference. The effect is the same as if the subclass is calling one of its own methods.


Consider a subclass Employee that extends its superclass Person:

 public class Employee extends Person{
   public Employee()
     //reference the superclass constructor 
   public String getName()
     //reference superclass behaviors
     return super.getFirstName() + " " + super.getLastName();

The super keyword can be used to reference the constructer of the Person class or any of the behaviors or fields that it has access to (e.g., getFirstName() and getLastName()).


# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

©2014 About.com. All rights reserved.