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
Explain the concept of proper inheritance?
How does multithreading take place on a computer with a single cpu?
What is binary search in java?
What are thread local variables?
What does s mean in regex?
What is runtime polymorphism or dynamic method dispatch?
Can a final variable be manipulated in java?
Can static method access instance variables ?
What is fail fast in java?
Why stringbuilder is not thread safe in java?
Should you use singleton pattern?
What do you understand by garbage collection in Java? Can it be forced to run?
When a byte datatype is used?
Why java is not 100% object-oriented?
What is the null?