Below is the piece of code I am trying to work on but unable to sort out the issue: "Can I really do the below in Java.. If yes please help to know me "How" and if no "Why?" "... Have a look at the code below...
class Base{
public void func(){
System.out.println("In Base Class func method !!");
};
}
class Derived extends Base{
public void func(){ // Method Overriding
System.out.println("In Derived Class func method");
}
public void func2(){ // How to access this by Base class reference
System.out.println("In Derived Class func2 method");
}
}
class InheritDemo{
public static void main(String [] args){
Base B= new Derived();
B.func2(); // <--- Can I access this ??? This is the issue...
}
}
Thanks in advance!!!! Waiting for some helpful answers :) ...