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
How can you share data between two thread in Java?
What is static class
What is the final class?
How to access arraylist elements in java?
What is difference between module and function?
Is string a class?
What is the equal sign?
What is difference between c++ and java ?
How do you use find and replace?
What is array length?
What is append function?
What is empty string literal in java?
How does a for loop work java?
How does finally block differ from finalize() method?
How we can declare a static variable?