is there a defined function name SUPER( ) in java? what it does?
vp
super is a method which allows access to public/protected methods/variables of the parent class. The parent class is the one which is extended by the class in which the super() call is made. super() by itself makes a call to the parent class's default constructor.
So---
class Test
{
public String strTest;
public Test
(
)
{
System.out.println("Hello World");
}
}
class SubTest extends Test
{
public Subtest
(
)
{
super();
}
}
class Driver
{
public Driver
(
)
{
}
public static void main
(
String args[]
)
{
SubTest st1 = new SubTest();
}
}
Even though the main method never makes any calls to the Test class, "Hello World" will be displayed anyways, b/c of the super() call in the SubTest class ... Copy and paste it and try it.
Mike