Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: keywords

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default keywords

    hi friends,

    can anyone tell me the difference between

    extend and implement

    class implements interface and interface implements interface


  2. #2
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: keywords

    Here is a link that you should read. It teaches you everything about OOP. http://download.oracle.com/javase/tutorial/java/concepts/index.html

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: keywords

    Extends can be used in two different contexts: an interface extending another interface, or a class extending another class. Implements can only be use in the context of a class implementing an interface. An interface can never extend/implement a class, and a class can never extend an interface. Classes are allowed to implement multiple interfaces but can only extend one class. Interfaces can extend any number of interfaces they want to.

    Syntaxes:

    public class BaseClass
    {}
     
    public interface BaseInterface
    {}
     
    public class ClassA extends BaseClass
    {}
     
    public class ClassB implements BaseInterface
    {}
     
    public interface InterfaceA extends BaseInterface
    {}
     
    public interface InterfaceB
    {}
     
    public class ClassB implements InterfaceA, InterfaceB
    {}
     
    public interface InterfaceC extends InterfaceA, InterfaceB
    {}

Similar Threads

  1. how to extract variables,keywords,operator...
    By Nanda in forum Java Theory & Questions
    Replies: 1
    Last Post: November 12th, 2009, 10:19 PM