Showing posts with label superclass. Show all posts
Showing posts with label superclass. Show all posts

Get superclass for an object class ???

Source code below will get superclass for it's own object class. It will print name for it's superclass.

*****************************************************************
COMPLETE SOURCE CODE FOR : GettingSuperclass.java
*****************************************************************


public class GettingSuperclass
{
public static void main(String[]args)
{
try
{
Class temp=Class.forName("GettingSuperclass");
Class thisIsSuper=temp.getSuperclass();

System.out.println("Superclass for this class is : "+thisIsSuper.getSimpleName());
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************

RELAXING NATURE VIDEO