Which of the following is true?
1. A class can extend more than one class.
2. A class can extend only one class but many interfaces.
3. An interface can extend many interfaces.
4. An interface can implement many interfaces.
5. A class can extend one class and implement many interfaces.
A. 1 and 2
B. 2 and 4
C. 3 and 5
D. 3 and 4
E. 2 and 5
Answer: Option C
Here only 2 and 5 are correct.. 3 is not correct because a class can never extend a interface it only implements any number of interfaces. And here 2 is correct because a class can extend only one class but implement many interfaces.
3rd statement is correct because there is no parent class for interface. In case of a class , the super class is object class.
Ex: class A extends Interface1, Interface2, Interface3..... Hence multiple interfaces can be inherited.
can you give simple example of An interface can extend many interfaces?