Computer Science 225
Advanced Programming

Spring 2017, Siena College

Hidden3 BlueJ Project

Click here to download a BlueJ project for Hidden3.


Hidden3 Source Code

The Java source code for Hidden3 is below. Click on a file name to download it.


Hidden3.java

/*
 * Example Hidden3: yet another hiding example
 *
 * Based on example by Darren Lim, Siena College, Computer Science 225
 */

class HidingInheritance
{
    public int x = 1;

    public void printX()
    {
        System.out.println(x);
    }
}

class Subclass extends HidingInheritance
{
    public int x = 2;
    public void printX()
    {
        super.printX();
        System.out.println(x);
    }
}

public class Hidden3 {
    public static void main(String[] args) {
        Subclass s = new Subclass();
        s.printX();

    }
}