hi friends,
can anyone tell me the difference between
extend and implement
class implements interface and interface implements interface
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.
hi friends,
can anyone tell me the difference between
extend and implement
class implements interface and interface implements interface
Here is a link that you should read. It teaches you everything about OOP. http://download.oracle.com/javase/tutorial/java/concepts/index.html
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 {}