Access Modifier : Protected

in Hindi - Access Modifier : Protected



not yet

Source Code :

RUN<div class="col-sm-12">
<div class="col-sm-6">
<h4>X.java</h4>
<pre>
package xyz;
public class X{

protected void show(){
System.out.println("This class name is X");

}
}</pre>
</div>
<div class="col-sm-6" style="margin-top:-18px">
<h4>Y.java</h4>
<pre>
import xyz.*;

class Y extends X{
public static void main(String args[]){
Y obj = new Y();
obj.show();
}
}

Output :
This class name is X
</pre>
</div>
</div>