How multipleInheritance is possible in java?
Answer Posted / srikanth
Multiple Inheritance is possible in java through interfaces only. Where as in C++ it is possible through classes also. Because in C++ there is one operator called scope Resolution operator, by this we can uniquely call one method of super classes. But we have no such operator in java, so it is not possible for a class to be inherited from multiple classes but possible with interfaces. For example,
class MyClass implements interface1,interface2....
{
// code
}
One more thing is, we can define our class from combination of interface and class also. But, combination should contain only one class and one or more interfaces. Ultimately class should be inherited from one class only.
class MyClass extends Class1 implements interface
{
//code
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Which java version is latest?
What is use of inner class in java?
What is overriding in java?
What is the history of java?
Which is bigger float or double?
Write a method to check if input string is palindrome?
Can we declare a class as abstract without having any abstract method?
Why do we use variables?
How many threads can java run?
What is java life cycle?
What is the differences between c++ and java? Explain
What does you mean in math?
Can we override static methods in java?
What is the size of string?
What is an accessor?