Why java Don't Support Multiple interitence
Answer Posted / bhaskar reddy
There is a big reason behind that(java does not support
multiple inheritance). Please go through the following
example.
1. Assume that java is supporting multiple inheritance
class A {
void m1() {
// implement method
}
}
class B {
void m1() {
// implement method
}
}
//As for the assumption (1) the following code will compile
class C extends A,B {
public static void main( String s[]) {
C c = new C();
c.m1();
}
}
Note : In main method i am calling c.m1() method In this
situation which super class m1 method has to call (from A
or B) JVM will confuse.
So our assumtion(1) is wrong .
This is the reason why java does not support multple
inheritance through classes.
Note : This same cocept is applicable for classes.
Is This Answer Correct ? | 29 Yes | 4 No |
Post New Answer View All Answers
What are nested classes in java?
Which data type is a class in java?
what is the purpose of "virtual"?
please send me hr interview questions in it industry
What is the biggest integer?
Explain super keyword in java.
Explain the importance of finally block in java?
When do we use hashset over treeset?
Say you want to store the information about a number of pets in an array. Typical information that you could store for each pet (where relevant) would be • Breed of animal • Animal's name • Its birth date • Its sex • Whether it has been sterilised or not • When it is due for its next inoculation • When it last had its wings clipped For each type of pet (eg. dog, cat or bird) you would typically define a class to hold the relevant data. Note: You do not need to implement these classes. Just answer the following questions. 3.1.1 What would be the advantage of creating a superclass (eg. Pet) and declaring an array of Pet objects over simply using an array of Objects, storing each of the instances of the different pet classes (eg. Dog, Cat or Bird) in it? 3.1.2 Would you define Pet as a class or as an interface? Why? (2) (2)
What is one third plus one third as a fraction?
Can we increase array size dynamically in java?
Is there any way to find whether software installed in the
system is registered by just providing the .exe file?
I have tried the following code but its just displaying the
directory structure in the registry.
Here the code :
package com.msi.intaller;
import java.util.Iterator;
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RootKey;
public class RegistryFinder {
public static void main(String... args) throws Exception
{
RegistryKey.initialize(RegistryFinder.class.getResource("jRe
gistryKey.dll").getFile());
RegistryKey key = new RegistryKey(RootKey.HKLM,
"Software\\ODBC");
for (Iterator
What do you understand by the term polymorphism?
How to compare two strings in java program?
Is there any limitation of using inheritance?