Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any technical difference between a subclass and an inherited class?

Is there any technical difference between a class which inherits from another class and a class which is a subclass of it? What's the difference between A and B in the following code:

A)

public class foo {
 ...
 private class bar {...}
}

B)

public class foo { ...}

private class bar extends foo {...}
like image 581
Ali Ghanavatian Avatar asked Jun 28 '11 07:06

Ali Ghanavatian


1 Answers

You're mixing terms. A subclass is the same as an inherited class.

In example A, bar is an inner class. An inner class is like a nested type. bar can see all the private stuff from foo but it's not itself a foo (you can't cast bar to foo).

like image 118
Aaron Digulla Avatar answered Sep 17 '22 18:09

Aaron Digulla