P
Patel
Is there a way to directly access a Super-Class method from an
instance of Sub-class.
eg.
public class ClassA
{
void Perform()
{
System.out.print("ClassA");
}
}
public class ClassB extends ClassA
{
public static void main(String[] args)
{
ClassB objB = new ClassB();
ClassA objA = (ClassA) objB;
objA.Perform();
}
void Perform()
{
System.out.print("ClassB");
}
}
This code would print out -- ClassB
But what I am looking at is, Is there a way to make a Perform() call
from instance of ClassB and achieve the result as -- ClassA.
I am new to OO programming.
Thanks,
Sajid
instance of Sub-class.
eg.
public class ClassA
{
void Perform()
{
System.out.print("ClassA");
}
}
public class ClassB extends ClassA
{
public static void main(String[] args)
{
ClassB objB = new ClassB();
ClassA objA = (ClassA) objB;
objA.Perform();
}
void Perform()
{
System.out.print("ClassB");
}
}
This code would print out -- ClassB
But what I am looking at is, Is there a way to make a Perform() call
from instance of ClassB and achieve the result as -- ClassA.
I am new to OO programming.
Thanks,
Sajid