Results 1 to 10 of 10

Thread: Interface

  1. #1
    usermahesh is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default Interface

    what is the difference between interface and abstract class real time example?

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Interface is basically a fully abstract class. An abstract class can have actual methods as well as abstract. It's generally better to use interfaces. You can implement as many interfaces as you want, but only extend one class.

  3. #3
    usermahesh is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    ya i know that ,but we can use abstract class with only abstract methods instead of interface,can you give real time example.

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Check the java source files, in java.util.collection you will see classes like "AbstractSet", "AbstractList", etc.

    You can also get lots of examples with google.

  5. #5
    usermahesh is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    real world example,regarding interface.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Interface is basically a fully abstract class.
    Not quite.
    You can implement many interfaces
    but you can only extend one class.

    I look at interfaces as part of the tight typing part of java. It allows you to give another type to a class so the compiler can check when a specific type is required as an arg to a method. There are other uses also. Like Serializable that is a flag that can be checked to see if a class can be processed a certain way.

  7. #7
    12345 is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    what is abstract

  8. #8
    12345 is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    why are using abstract in java

  9. #9
    12345 is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    what is trasient and why are using this

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    The question is off topic for this forum, which is for member introductions. Locking up here.

    db

Similar Threads

  1. Is there a GUI interface for...
    By smith427 in forum New To Java
    Replies: 3
    Last Post: 12-03-2009, 07:17 AM
  2. How do I use an Interface for this?
    By aaronfsimons in forum New To Java
    Replies: 14
    Last Post: 06-22-2009, 02:19 PM

Posting Permissions

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