Computer Science, asked by kadamsidharth8, 6 months ago

Q4

Which of the following statement(s) is (are) CORRECT regarding an interface in Java?

a. An interface can contain only abstract methods and standard methods but no static
methods are allowed.

b. Method bodies in an interface doesn't exist for default methods and abstract methods.

C. An interfaces cannot be instantiated but can be implemented by classes.

d. An interfaces cannot be instantiated but can be extended by other interfaces.

Answers

Answered by saimithraakuthota028
0

Explanation:

1. Yes, a class can implement multiple interfaces. Each interface provides contract for some sort of behavior.

2.A class can implement more than one interface at a time. A class can extend only one class, but implement many interfaces. An interface can extend another interface, in a similar way as a class can extend another class.

3. The implementation of interface's members will be given by the class who implements the interface implicitly or explicitly. C# allows the implementation of multiple interfaces with the same method name.

Answered by sharonr
0

d. An interfaces cannot be instantiated but can be extended by other interfaces is the correct statement.

Explanation:

  • Interfaces can't be created from scratch. Only an implementing class or another interface can implement or extend them.
  • All of the methods defined in the interface must be implemented by a class that implements the interface.
  • An interface can extend other interfaces in the same way that a class can extend or subclass another class.
  • A comma-separated list of all the interfaces that it extends is included in the interface definition.

#SPJ2

Similar questions