---
title: "Which class is a superclass of all classes?"  
description: "Which class is a superclass of all classes?"  
author: "Mukul Goenka"  
published: 2021-11-24  
updated: 2023-06-16  
canonical: https://www.mindstick.com/interview/33847/which-class-is-a-superclass-of-all-classes  
category: "java"  
tags: ["java", "programming language"]  
reading_time: 2 minutes  

---

# Which class is a superclass of all classes?

Java.lang package, The object is the root class for all the java classes and we don’t need to extend it. Every other java classes fall back under the object. All the different non-primitive types including arrays are inherited directly or indirectly from this class.

## Answers

### Answer by Aryan Kumar

The Object class is the superclass of all classes in Java. It is located in the java.lang package. All classes, including arrays, inherit from the Object class. This means that all classes have the methods and properties of the Object class, even if they do not explicitly reference them.

The Object class provides a number of methods and properties that are common to all objects, such as the equals, hashCode, and toString methods. It also provides the finalize method, which is called by the garbage collector when an object is about to be garbage collected.

The Object class is an abstract class, which means that it cannot be instantiated. However, it is still an important class in Java, as it provides the foundation for all other classes.

Here are some of the methods and properties of the Object class:

- equals(): This method compares two objects for equality.
- hashCode(): This method returns a hash code for an object.
- toString(): This method returns a string representation of an object.
- finalize(): This method is called by the garbage collector when an object is about to be garbage collected.

### Answer by Mukul Goenka

Java.lang package, The object is the root class for all the java classes and we don’t need to extend it. Every other java classes fall back under the object. All the different non-primitive types including arrays are inherited directly or indirectly from this class.


---

Original Source: https://www.mindstick.com/interview/33847/which-class-is-a-superclass-of-all-classes

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
