Results 1 to 8 of 8
  1. #1
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default interface vs abstract classes

    Hey is there a good website, that explains using classes implementing interfaces, with the help of a full explained code. I have gone through website, but wasnt of much help. I have questions as to how to create a driver program like 'public static void main()'. There are several other questions as such about if a function is written in the interface; how to call objects of the class as input.

    Please suggest.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    1) Have you gone through the Sun tutorials on this subject? That's always where I start.
    2) Please go into further details on just what you mean by a "driver program". You mention a static method, and as far as I know, static doesn't work with interfaces.
    3) Have you tried creating an interface and used the interface name itself as a parameter to one of its methods? If so, did it compile?

  3. #3
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    I have not done anything. I just want to learn interfaces first, before implemeting. Also, how to call functions(i.e) how to create a driver program.
    Ive gone through sun tutorial, but it just gives a brief introduction, not to the depth of what I need to know.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Again, what the heck do you mean by a "driver" program. Please go into a bit more detail, with examples if you can think of any as I'm not clear on just what you're trying to do.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Also, the Interface Tutorial that I've study at the Sun site seemed to go into quite a bit of detail, and in fact though it is all I've ever studied on the subject I feel quite comfortable with using this construct. Are you sure that you've been through the same tutorial as I? You can find it here:

    Interfaces (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)

  6. #6
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    In a regular program that deals with basic class, I will have a main class(driver program) that initializes values, calls functions.

    Java Code:
    class XXX
    {
        constructor()
        function a(){};
        function b(){};
        main()
        {
             function a();
             function b(){};
         }
    }
    how could I do this with an interface?
    Java Code:
    interface XXX
    {
      function a();
      function b();
    }
    class YYY implements XXX
    {
      constructor()
        function a(){};
        function b(){};
    }

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I'm sorry, it may be me, but I'm still not clear what the hang up is. Your driver I suppose would have variables of the interface type, would initialize it with a concrete class that implements the interface, and then would call the methods as needed.

  8. #8
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

Similar Threads

  1. difference between Abstract and interface
    By mrark in forum New To Java
    Replies: 3
    Last Post: 11-07-2009, 05:20 AM
  2. Interface and Abstract Class
    By kian_hong2000 in forum New To Java
    Replies: 1
    Last Post: 08-27-2008, 03:22 PM
  3. Interface Vs Abstract Class
    By javarishi in forum New To Java
    Replies: 5
    Last Post: 06-15-2008, 06:43 AM
  4. Inverfaces vs Abstract Classes
    By ravian in forum New To Java
    Replies: 1
    Last Post: 11-28-2007, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •