![Alok mishra](https://www.crazyengineers.com/img/avatar.jpg)
Member • Sep 4, 2013
Member • Sep 4, 2013
Member • Sep 4, 2013
Member • Sep 4, 2013
Member • Sep 4, 2013
Member • Sep 4, 2013
Administrator • Sep 4, 2013
Member • Sep 4, 2013
Animal (I) {method: motion} | / \__ / \ Seal Man (c) (c) \ UsionBolt (c) (I)-Interface (c) -Class Let say these three classes have overrriden method motion() and implemented according to their need. Now as per coding standard you will write like this Animal animalA = new Seal(); Animal animalB = new Man(); Animal animalC = new UsionBolt();Creating new object is not necessary to be created like this and quite possible that there will be more than two level of hierarchy of classes.
Member • Sep 4, 2013
Member • Sep 4, 2013
<a href="https://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html#start()" target="_blank" rel="nofollow noopener noreferrer">Thread (Java Platform SE 6)</a>()So you have to implement run() and then write your code inside it to run as separate thread.
Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
I feel overriden methods are abstract in their original classes ,is it so ?It's upon your requirement that your original overridden method should be abstract or concrete. see my first example in Animal interface , method motion is abstract while in class Man and UsionBolt it's concrete. you can code without interfaces but it is highly recommended to have interface and you should access any class by interface type only.
Member • Sep 4, 2013
Member • Sep 4, 2013
Dear, JAVA doesn't support multiple inheritance. Interface is used to implement multiple inheritance in JAVA.Alok mishraYes because it helps implementing mulpile inheritence . Extending a class can affect execution time
Member • Sep 4, 2013
Member • Sep 4, 2013
Member • Sep 4, 2013
Nope, multilevel works and that's is true property of inheritance.Alok mishrabecause that becomes obsolete when there is multilevel and hierarchical type inheritances .
Member • Sep 5, 2013
Because there rises no need of it , one can inherit power of two classes by using only multilevel inheritence . Thats why i called multiple inheritence obsolete.ianoopNope, multilevel works and that's is true property of inheritance.
Like in example man is inheriting Animal and Man again inherited by Usion Bold so UsionBolt will have default properties of Animal+Man.
Question is why can't a class can extend two classes, what will be consequences ?
Member • Sep 5, 2013
C++ and python supports multiple inheritance - so it's not necessarily obsolete.Alok mishraBecause there rises no need of it , one can inherit power of two classes by using only multilevel inheritence . Thats why i called multiple inheritence obsolete.
Member • Sep 9, 2013
i meant obsolete to javaAnand TamariyaC++ and python supports multiple inheritance - so it's not necessarily obsolete.
Member • Sep 9, 2013
Member • Sep 9, 2013
ianoopNo, it's not absolute. The problem is when you are extending two classes and both parent class have any common method.
How could you solve this problem!!
ianoopNo, it's not absolute. The problem is when you are extending two classes and both parent class have any common method.
How could you solve this problem!!
Member • Sep 9, 2013