| | |
Multiple Inheritence
![]() |
•
•
Join Date: Apr 2008
Posts: 972
Reputation:
Solved Threads: 145
You can inherit from a single parent downwards as far as you want...
A extends Object; B extends A; C extends B; etc
Thus, by implication, C extends B, A, and Object.
What you can't do is this:
E extends F,G
ie. extend from two parents at the same level. This is what Java refers to a multiple inheritance.
A extends Object; B extends A; C extends B; etc
Thus, by implication, C extends B, A, and Object.
What you can't do is this:
E extends F,G
ie. extend from two parents at the same level. This is what Java refers to a multiple inheritance.
Last edited by JamesCherrill; Sep 26th, 2009 at 9:57 am.
•
•
Join Date: Apr 2008
Posts: 972
Reputation:
Solved Threads: 145
It's single inheritance. Each class inherits from 1 class only, but that class, in turn,inherits from one class, etc, all the way up to Object.
When your code refers to a method or variable in a class Java looks for that method/variable in the class definition. If it finds it, OK. If not, it looks in the definition of the superclass. If it finds it there, OK. If not, it looks in that classes' superclass etc, all the way to Object. I it doesn't find it in Object you get a compile error.
When your code refers to a method or variable in a class Java looks for that method/variable in the class definition. If it finds it, OK. If not, it looks in the definition of the superclass. If it finds it there, OK. If not, it looks in that classes' superclass etc, all the way to Object. I it doesn't find it in Object you get a compile error.
![]() |
Similar Threads
- Multiple webcams (USB Devices and other Peripherals)
- Search with multiple search terms used (PHP)
- does java support Multiple inheritence via interfaces (Java)
- Inheritance (Java)
- hi uegent (C#)
- QuickSort (Computer Science)
Other Threads in the Java Forum
- Previous Thread: Error Scanner Loading
- Next Thread: HELP<!>Program doesn't get user input from the 2nd Textfield(KAEquation)
| Thread Tools | Search this Thread |
add android api applet application applications array arrays automation bank binary bluetooth chat class clear client code codesnippet collections component converter database development dice digit eclipse equation error event formatingtextintooltipjava fractal functiontesting game givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jni jpanel julia linux list loop looping main map method methods mobile myregfun mysql netbeans newbie nonstatic openjavafx parameter pearl php print problem program programming project recursion repositories scanner scrollbar server set size sms sort sorting spamblocker sql sqlserver state storm string superclass swing swt text-file thread threads tree windows






