| | |
Multiple Inheritence
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2008
Posts: 1,020
Reputation:
Solved Threads: 151
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: 1,020
Reputation:
Solved Threads: 151
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)
Views: 350 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addressbook android api append apple applet application arguments array arrays automation binary bluetooth chat class classes client code component csv database draw eclipse error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me japplet java javaarraylist javaprojects jmf jni jpanel julia linked linux list loop map method methods mobile netbeans newbie number object objects oracle oriented panel print printf problem program programming project projects recursion replaydirector reporting researchinmotion return robot rotatetext scanner score screen se server set size sms socket sort sql stream string swing test threads time transfer tree ubuntu windows






