Computer Science 225
Advanced Programming

Spring 2017, Siena College

Hidden2 BlueJ Project

Click here to download a BlueJ project for Hidden2.


Hidden2 Source Code

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


Hidden2.java

/*
 * Example Hidden2: another hiding example
 *
 * Example by Darren Lim, Siena College, CSIS 225
 *
 */

public class Hidden2 {

    public static void main(String[] args) {
        Account a = new MyAccount(); //OK or Not OK

        a.print2();  //Output?

        MyAccount a2 = new MyAccount(); //OK or Not OK
        a2.print2();	//Output?

    }
}

Account.java


/**
 * Account class for Hidden2 example
 */
public class Account
{
    public double value = 100.0;

    public void print2()
    {
        System.out.println( 2 * value);
    }
}

MyAccount.java


/**
 * MyAccount class for Hidden2 example
 */
public class MyAccount extends Account
{
    public double value = 1000.0;
}