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


Please Help Members By Posting Answers For Below Questions

How can you share data between two thread in Java?

526


What is static class

620


What is the final class?

550


How to access arraylist elements in java?

493


What is difference between module and function?

542






Is string a class?

556


What is the equal sign?

565


What is difference between c++ and java ?

671


How do you use find and replace?

511


What is array length?

507


What is append function?

570


What is empty string literal in java?

562


How does a for loop work java?

543


How does finally block differ from finalize() method?

587


How we can declare a static variable?

654