In this program, You will learn how to implement the protected keyword in java.
Access modifiers in java: public, private, protected and default
class A {
protected int x = 10;
}
class Main extends A {
void print() {
System.out.println("The x value is :" + x);
}
public static void main(String args[]) {
Main obj = new Main();
obj.print();
}
}
The x value is :10