Let's say there are two classes Employee and Student. According to your example
Employee emp=new Student()
Employee class should be the parent class and Student class is the child class. Let's say child accesses parent's members. It's just like this;
class Employee{
String empName = "John";
}
class Student extends Employee{
int age = 20;
}
class Test{
public static void main(String[] args){
Student s= new Student();
System.out.println(s.empName); //valid since child class can access members of
parent class
System.out.println(s.age); //valid
Employee emp=new Student(); //your example
System.out.println(emp.empName); //valid
System.out.println(emp.age); //not valid since parent class can't access child members
}
}