C# Programming - Interfaces - Discussion
Discussion Forum : Interfaces - General Questions (Q.No. 1)
1.
Which of the following statements is correct about the C#.NET code snippet given below?
interface IMyInterface
{
void fun1();
int fun2();
}
class MyClass: IMyInterface
{
void fun1()
{ }
int IMyInterface.fun2()
{ }
}
Discussion:
15 comments Page 2 of 2.
Sandeep said:
1 decade ago
fun1() must be public in my class and fun2() must return a value of int type and there is no need to make int IMyInterface.fun2() public because it is explicit implementation which is private to class.
Pramod Khandare said:
1 decade ago
No need to give Interface name while giving definition to method void fun1().
Ajay yadav said:
1 decade ago
In this program how could we directly call the method from base class with out creating the obj of the class ! it only be possible while be use static keyword.
VijayaKumar r said:
1 decade ago
It's correct, because if implicit implementation, first function must mark as public before return type, or go for explicit implementation.
Mahdi said:
1 decade ago
The answer is wrong because
1.fun2 should return an int value
2. fun1 and fun2 in Myclass should be public
1.fun2 should return an int value
2. fun1 and fun2 in Myclass should be public
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers