Java Program to Get the Name of the Superclass

You are currently viewing Java Program to Get the Name of the Superclass

Java program to get the name of the superclass

// Java program to get the name of the 
// superclass

class A 
{}

class B extends A 
{}

public class Main
{
	public static void main(String[] args)  throws ClassNotFoundException
	{
	    	Class cls = B.class; 
        
        		System.out.println("The superclass is: "+cls.getSuperclass());
	}
}

Output

The superclass is: class A

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply