F
frank
I'm new bee to java . In the below program I had created the parent
object in the
reference of child class. When the object creation is inside the
method. I
am not getting any error. If the object creation is in the class
level. I am
getting the error in accessing the method. tel me Why can't
access the the method in side the class..?
Thanks In Advance...
class Employee {
public void ss(){
System.out.println("Testing The Casting");
Employee mn = new Manager();
Manager t = new Manager();
Manager kk = (Manager) new Employee();
kk.manage();
}
{ " Manager kk = (Manager) new Employee();
kk.manage(); " } -------------- Error in this line..
}
class Manager extends Employee {
public void manage() {
System.out.println("Managing ...");
}
}
object in the
reference of child class. When the object creation is inside the
method. I
am not getting any error. If the object creation is in the class
level. I am
getting the error in accessing the method. tel me Why can't
access the the method in side the class..?
Thanks In Advance...
class Employee {
public void ss(){
System.out.println("Testing The Casting");
Employee mn = new Manager();
Manager t = new Manager();
Manager kk = (Manager) new Employee();
kk.manage();
}
{ " Manager kk = (Manager) new Employee();
kk.manage(); " } -------------- Error in this line..
}
class Manager extends Employee {
public void manage() {
System.out.println("Managing ...");
}
}