My Base class in one package
package com.practice.array;
public class Employee {
private int age=1;
protected String name="string";
public String lastname="string1";
String familyName="string2";
}
and child class in other package
package com.practice.binarytree;
import com.practice.array.Employee;
public class Demo extends Employee{
public static void main(String[] args) {
Employee emp = new Employee();
System.out.println(emp.name);//getting compile time error here
}
}
Here I am getting compile time error as change visibility of 'name' to 'protected' but name variable is already declared as 'protected'