- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the super class of every class in Java?
The class named Object is the super class of every class in Java.
Let’s test it with an example. The java.lang.Class.getSuperclass() returns the Class representing the superclass of the entity (class, interface, primitive type or void) represented by this Class.
So, Create a sample concrete class and lets try to get the name of its super class using this method.
Example
public class Test { public static void main(String args[]){ Test obj = new Test(); Class cls = obj.getClass().getSuperclass(); System.out.println(cls.getName()); } }
Output
Since the Object class is the super class of all classes it displays the name of the object class as shown below.
java.lang.Object
- Related Articles
- Why Object class is the super class for all classes in Java?
- Get super class of an object in Java
- What is the class "class" in Java?
- Can super class reference variable hold sub class's object in java?
- How to ensure that child class overrides a super class method in java?
- How to convert a sub class variable into a super class type in Java?
- How to convert a super class variable into a sub class type in Java
- Variable in subclass hides the variable in the super class in Java
- How do we check if a class is a subclass of the given super class in Python?
- Java Program to create String to super class type mapping
- What is the root class in Java?
- What is the object class in Java?
- What is the Thread class in Java?
- What happens if we call "super()" in a constructor without extending any class, in java?
- What is the difference between Component class and Container class in Java?

Advertisements