Title: Access Levels with Protected
Course: CPS 161: An Intro to Programming with Java - DL MM MASTER

Access Levels with Protected


package one;

public class A {
    public void method_public()
    {

    }
    void method_default()
    {

    }
    private void method_private()
    {

    }
    protected void method_protected()
    {

    }

}
//******************************************************
package one;

public class B {
    void doit()
    {
        A a = new A();
        a.method_public();
        a.method_default();
        a.method_protected();
        //a.method_private();

    }

}

//******************************************************
package two;

import one.A;

public class B {
    void doit()
    {
        A a = new A();
        a.method_public();
        //a.method_default();
        //a.method_protected();
        //a.method_private();

    }

}

//******************************************************
package two;

import one.A;

public class ExtendedFrom_A extends A{
    void doit()
    {
        A a = new A();
        a.method_public();
        //a.method_default();
        //a.method_protected();
        //a.method_private();

        method_protected();

    }

}




Last Modified: March 28, 2014 1:12 PM