Wednesday, 28 March 2018

Access modifier in java







package javaapplication21;





class A

{

  protected  String name="abcd"; 

private void msg1()

{

    System.out.println("hello this is msg1 and private");

}



protected void msg2()

{

    System.out.println("hello this is msg2 and protected");

}



}



class B extends A

{

public void showname()

{

 System.out.println("name is "+name);

}

}

public class JavaApplication21

{

    public static void main(String[] args)

    {

    B a=new B();

    a.msg2();

    a.showname();



     

     

       

    }

   

}


No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...