- 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 root class in Java?
The Object class of the java.lang package is the root class in Java i.e. It is the super class of every user-defined/predefined class n Java. All objects, including arrays, implement the methods of this class.
The reason for this is to have common functionalities such as synchronization, garbage collection, collection support, object cloning for all objects in Java.
The class named Class of java.lang package provides a method named getSuperclass() this method returns the Class representing the superclass of the current Class.
So, Create a sample concrete class and try to get the name of its super class using this method.
Example
public class Sample { public static void main(String args[]) { Sample obj = new Sample (); 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
- What is the class "class" in Java?
- What is the object class in Java?
- What is the Thread class in Java?
- What is the super class of every class in Java?
- What is AbstractSequentialList class in Java?
- What is AbstractCollection class in Java?
- What is AbstractList Class in Java?
- What is the difference between Component class and Container class in Java?
- What is Java String Class?
- What is the purpose of System class in Java?
- What is the purpose of Runtime class in Java?
- What is the package for String Class in Java?
- What is the importance of SwingUtilities class in Java?
- What is the importance of JViewport class in Java?
- What is the importance of JSeparator class in Java?

Advertisements