Results 1 to 3 of 3
  1. #1
    sivasayanth's Avatar
    sivasayanth is offline Member
    Join Date
    Dec 2007
    Posts
    20
    Rep Power
    0

    Lightbulb i couid not get the idea:

    In Java, a class can inherit from only one class but it can implement more than one interface


    what does it mean? i couldn't understand !:confused:

  2. #2
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default

    Hello sivasayanth

    Java does not support multiple inheritance. So, you cannot create a child that inherits members from two parents. The solution for this is interfaces. Interfaces allow us to create classes that have related members or attributes to other classes weather they are related by inheritance or not. Let's take an example:
    Let's say that we have a class Car and two interfaces Stoppable and Turnable. Also, we have two classes Stop and Turn. If you want your car to be able to stop and turn, you must let the Car class implement the Stoppable and Turnable interfaces. It is not possible to create a class, Car, that is extended from both Stop and Turn.
    I hope this helped. ;)
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  3. #3
    sivasayanth's Avatar
    sivasayanth is offline Member
    Join Date
    Dec 2007
    Posts
    20
    Rep Power
    0

Similar Threads

  1. Got an Idea, Just Share it!
    By james in forum Java Software
    Replies: 0
    Last Post: 03-18-2008, 12:09 PM
  2. anyone can give idea 2 my assignment?
    By chen8735 in forum Advanced Java
    Replies: 2
    Last Post: 03-08-2008, 06:03 PM
  3. Need a idea on GridBagLayout
    By ddsuresh in forum AWT / Swing
    Replies: 1
    Last Post: 01-29-2008, 01:32 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
  •