---
title: "What is the difference between an Inner Class and a Sub-Class?"  
description: "What is the difference between an Inner Class and a Sub-Class?"  
author: "Jivika Rai"  
published: 2017-12-19  
canonical: https://answers.mindstick.com/qa/31844/what-is-the-difference-between-an-inner-class-and-a-sub-class  
category: "technology"  
tags: ["java programming"]  
reading_time: 1 minute  

---

#  What is the difference between an Inner Class and a Sub-Class?

What is the [difference](https://www.mindstick.com/blog/398/difference-between-object-type-and-var-type) between an [Inner Class](https://www.mindstick.com/articles/12104/nested-classes-in-java-more-with-inner-classes) and a Sub-Class?

## Answers

### Answer by Hemant Patel

The main difference between inner [class](https://www.mindstick.com/articles/12089/arrays-in-java-determining-class-of-an-array-part-8) and subclass is, An Sub-Class is a class which inherits all the non-private members of its parent Class. But an inner class is a class which is nested within another class, which rights for the class which is nesting it and it can access all variables and methods defined in the outer class. Inner classes have the methods they want, whereas sub-classes have the methods of their parent class. And Sub-classes can, of course, define additional methods, but they'll always have those of their parent.


---

Original Source: https://answers.mindstick.com/qa/31844/what-is-the-difference-between-an-inner-class-and-a-sub-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
