Access to sub-class parent variables in Java
Variables (instance variables, class variables, constants) and class methods are related to the compilation type.
The instance method is related to the runtime type (resulting in polymorphism)
ClassA
{
Public Static Int H= 10;
Public IntN = 10;
Public Static Final Int M= 10;
Public Static VoidPut ()
{
System.Out. Println ("");
}
Public VoidPut1 ()
{
System.Out. Println ("A1 ");
}
}
Public ClassSolutionExtendsA
{
Public Static Int H= 100;
Public IntN = 100;
Public Static Final Int M= 100;
Public Static VoidPut ()
{
System.Out. Println ("Solution ");
}
Public VoidPut1 ()
{
System.Out. Println ("Solution1 ");
}
Public Static VoidMain (String [] args)
{
A a =NewSolution ();
System.Out. Println (.H); // Class variable 10
System.Out. Println (a. n); // instance variable 10
System.Out. Println (.M); // Constant 10
A.Put(); // Class method
A. put1 (); // instance method Soultion1
}
}