Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:09:23+00:00 2026-06-05T06:09:23+00:00

I am aware that this is a very basic question, but an interviewer asked

  • 0

I am aware that this is a very basic question, but an interviewer asked me in a very trick way and I was helpless 🙁

I know only material or theoretical definition for an interface and also implemented it in many projects I worked on. But I really don’t understand why and how is this useful.

I also don’t understand one thing in interface. i.e for example, we use

conn.Dispose(); in finally block. But I don’t see that class is implementing or inheriting IDisposable interface (SqlConnection) class I mean. I am wondering how I can just call the method name. Also in the same thing, I am not understanding how Dispose method works as because, we need to implement the function body with our own implementation for all interface methods. So how Interfaces are accepted or named as contracts? These questions kept on rolling in my mind till now and frankly I never saw any good thread that would explain my questions in a way that I can understand.

MSDN as usual looks very scary and no single line is clear there (Folks, kindly excuse who are into high level development, I strongly feel that any code or article should reach the mind of anyone who see it, hence like many others say, MSDN is not of use).

The interviewer said:

He has 5 methods and he is happy to implement it in the class directly, but if you have to go for Abstract class or interface, which one you choose and why ? I did answered him all the stuffs that I read in various blog saying advantage and disadvantage of both abstract class and interface, but he is not convinced, he is trying to understand “Why Interface” in general. “Why abstract class” in general even if I can implement the same methods only one time and not gona change it.

I see no where in net, I could get an article that would explain me clearly about interfaces and its functioning. I am one of those many programmers, who still dont know about interfaces (I know theoretical and methods I used) but not satisfied that I understood it clearly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:09:24+00:00Added an answer on June 5, 2026 at 6:09 am

    Interfaces are excellent when you want to create something like it:

    using System;
    
    namespace MyInterfaceExample
    {
        public interface IMyLogInterface
        {
            //I want to have a specific method that I'll use in MyLogClass
            void WriteLog();       
        }
    
        public class MyClass : IMyLogInterface
        {
    
            public void WriteLog()
            {
                Console.Write("MyClass was Logged");
            }
        }
    
        public class MyOtherClass : IMyLogInterface
        {
    
            public void WriteLog()
            {
                Console.Write("MyOtherClass was Logged");
                Console.Write("And I Logged it different, than MyClass");
            }
        }
    
        public class MyLogClass
        {
            //I created a WriteLog method where I can pass as a parameter any object that implements IMyLogInterface.
            public static void WriteLog(IMyLogInterface myLogObject)
            {
                myLogObject.WriteLog(); //So I can use WriteLog here.
            }
        }
    
        public class MyMainClass
        {
            public void DoSomething()
            {
                MyClass aClass = new MyClass();
                MyOtherClass otherClass = new MyOtherClass();
    
                MyLogClass.WriteLog(aClass);//MyClass can log, and have his own implementation
                MyLogClass.WriteLog(otherClass); //As MyOtherClass also have his own implementation on how to log.
            }
        }
    }
    

    In my example, I could be a developer who writes MyLogClass, and the other developers, could create their classes, and when they wanted to log, they implement the interface IMyLogInterface. It is as they were asking me what they need to implement to use WriteLog() method in MyLogClass. The answer they will find in the interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm very aware that this is probably not a stackoverflow question, but i figure
I aware that this will be a less programming question, but still... How can
this may well be a very basic question, but I haven't been able to
I'm aware that MD5 has had some collisions but this is more of a
In the answer to this question ovanes states: Please be aware that boost::lexical_cast is
In this question , I was made aware of glob()'s GLOB_BRACE option that allows
Edit: I'm well aware of that this works very well with value types, my
This is my first question on this site, and I only have a basic
I am aware that this topic has been covered already in many places, but
I'm aware that you can do this: public ActionResult DoSomething([Bind(Exclude = CreationDate)] Item item)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.