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

Which java version is latest?

722


What is use of inner class in java?

741


What is overriding in java?

734


What is the history of java?

739


Which is bigger float or double?

744


Write a method to check if input string is palindrome?

758


Can we declare a class as abstract without having any abstract method?

754


Why do we use variables?

693


How many threads can java run?

796


What is java life cycle?

752


What is the differences between c++ and java? Explain

791


What does you mean in math?

753


Can we override static methods in java?

797


What is the size of string?

757


What is an accessor?

1312