Sunday, January 31, 2016

TestAccessModifiersExample3

package TestAccessModifiers;

import accessModifiers.TestAccessModifiers;

public class TestAccessModifiersExample3 extends TestAccessModifiers{

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

TestAccessModifiersExample3 obj = new TestAccessModifiersExample3();
obj.test1();
obj.test4();

System.out.println(obj.a);
System.out.println(obj.d);

/**
* Here test2() and test3() is not inherited by child class
* when we are trying to access members of class from different package class,
* we can access only public and protected members with inheritance.
*/

/**
* Through inheritance our child class can inherit only public and protected members
* when we are in different
* package
*/

/**
* only difference between protected and default access is, when we are in different
* package and when we are using inheritance , our child class will inherit
* protected members not default members.
*
*/

/**
* when we are in same
* package and when we are using inheritance , our child class will inherit
* protected and default members. it will inherit both access type
*
*/




}

}

1 comment:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    Core Java Training in Electronic city

    ReplyDelete