Multiple choice

Is the following code right with respect to the concept of Interfaces? What's wrong with the code if use it as it is?

public Interface ISum

{
public void Sum()
{
int a,b,result; /*Assuming that we have the user's values for a and b.*/
result = (a+b); } }

  1. We can't declare Interface like this

  2. We can't give body to Interface like this

  3. We can't give body to things like methods in the Interface like this

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Explanation: Interfaces do not have implementation within them. Instead, they are used as such and are given body wherever they are implemented. So, all the working done in the Sum() must not be there for the time being it is in the Interface ISum.