Interface extending another interface

Hi, i seem to have trouble finding on the internet what happends when one interface extends another interface. Can you explain it here or give me some link where i can find such information. Thanks

have you tried to create on yet?  sometimes the best way to learn is just to do it.
the truth is, extension of an interface is no different than the extension of a regular class.  when you finally implement your subClassed interface, you will just have to remember to add all unImplemented methods of both interfaces.  generally for soemthing like this its best to just implement multiple interfaces so that you will always know what you need to implement before run time otherwise you are bound to receive a lot of errors for not having implemented those methods.

Similar Messages

  • Can an abstract class extend another abstract class?

    Is it possible for an abstract class to extend another abstract class?
    Say
    public abstract class AComponent extends JComponent {
    Thanks.

    Yes

  • Can an EJB extend another EJB?

    Can an EJB extend another EJB?
    Are there any limitations?
    Thank you in advance, Kostas

    Refer
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=ejb-interest&F=&S=&P=31185

  • I just wanna extend another year warranty. i tried to register in, but failed.how to be done

    I just wanna extend another year warranty. i tried to register in, but failed

    Depending on your country and the Applecare level available there
    Currently Applecare+ has to be purchased within 30 days of purchasing the iPhone
    If you want to share more information then you will get a more accurate response

  • Custom mxml component extending another mxml component

    I want to create a custom mxml component that extends another mxml component. Bacially I want structure like Group -> BaseMXMLComponent -> MyMXMLComponent. I understand that it used to be the case that trying to add child component to MyMXMLComponent would throw "Error: Multiple sets of visual children have been specified for this component (base component definition and derived component definition)." error. But i've been reading few articles that says this has been fixed in Flex 4.
    My question is.. is it an actually fixed, documented, and supported behavior of Flex 4? or just an undefined behavior that appears to be "fixed" but can change on future update?

    I dont know what is happening inside datagrid.But If
    you want to maintain a single instance you could use singleton design pattern
    read about it
    http://en.wikipedia.org/wiki/Singleton_pattern
        public class Singleton
            private static var instance:Singleton= new Singleton();
            public var userdata:*; // keep user object
            public function Singleton()
                if (instance != null) { throw new Error('Cannot create a new instance.  Must use Singleton.getInstance().') }
            public static function getInstance():Singleton
                return instance;

  • Interface extends another interface

    Hi,
    Java has the concept of inheritance for both classes and interfaces.
    For classes inheritance is restricted to single inheritance. For multiple
    inheritance the class should implement an interface.
    But what about interfaces? Is multiple inheritance defined for interfaces?
    If so, is there any documentation on this? Are there OO-design-considerations
    that argue against multiple inheritance for interfaces?
    Thanks for your remark or pointing to literature,
    Sponiza

    You should try it and see. But, not to spoil the surprise, yes Java allows an interface to extend multiple interfaces, and yes, like most everything else there are design considerations to doing this. You might wade through the long discussion here:
    http://forum.java.sun.com/thread.jsp?thread=479908&forum=4&message=2241590
    and hit google or search these fora
    Good Luck
    Lee

  • Calling a constructor of an object that extends another object

    suppose you have the source:
    class A {
    public int x = 1;
    public int y = 5;
    public A(){y = 6;)
    class B extends A {
    public B(){}
    public B(int a) { super(a); }
    Now suppose in the main function you say
    B b1 = new B();
    I would think the value of x is 1 which it is, but the value of y is 6, why is this, I did not call the A constructor or does an object call the parameterless constructor of its superclass automatically. If that is the case, it will clarify to me why y gets the value of 6 and not 5.

    Unless you specify a super call, it will be done. The next two constructors are the same:public B () {
        x = 2;
    public B () {
        super ();
        x = 2;
    }Another thing for you to try: remove the A () constructor (but keep the A (int)) and see if B will still compile.
    Kind regards,
    Levi

  • Error 1119 when class extends another class that extends movieclip

    hiya
    i came across this problem and i have no clue why it's happening. basically, consider 2 nested movieclips on the stage, something like stage -> main -> filler.  both movieclips have instance names (main and filler).
    in the library, i set main to export for actionscript, using class A:
    package {
        import flash.display.MovieClip;
        public class A extends MovieClip {     
            public function A ():void {
                trace ('construct A');
                trace (this.filler); // should trace [movieclip] etc
    it works fine. now i change it's export settings to use class B, that extends A, and it breaks:
    package {
        import flash.display.MovieClip;
        public class B extends A {
            public function B ():void {
                trace ('construct B');
    this throws an error 1119: Access of possibly undefined property filler through a reference with static type A.
    can anyone give me a hint on that, as it works with class A, but not B extending A? i understand it was meant to work?
    many thanks

    afaik, if you dont declare super(), flash will make a call for you (but best practice is to call it always).
    but i found the "solution" in another forum.
    it seems that flash implicitly generates variables if you have instance names/symbols on the stage. there is an option to disable that under publish settings -> Actionscript version -> Settings -> automatically declare stage instances. by disabling that, we were able to declare public var filler:MovieClip; on class A, and that worked.
    although, that solution doesnt look attractive to me. the other solution posted on another forum was to make calls to this ["filler"] instead of this.filler. that seems to work fine. i guess it has to do with the automatic variable generated thing.. who knows?
    i hope that helps someone else too

  • When extending another class...?

    I have made a BinaryTree class, tested it and everything and it all works.
    Now, I have just made an AVLTree class. So, I want all the methods in the BinaryTree class to be the same as in the AVL class except the add method which I wanted to override.
    So, I made the BinaryTree class abstract, and then extended the BinaryTree class in the AVL class.
    So I thought that by doing this all I had to do was put in the add method and change the code and then I could use all the methods in the BinaryTree class.
    Well it seems that I can, except that none of it works correctly because of private attributes. For example, my size doesn't update in my new add method and I can't figure out why. I have a private int size in both classes but it doesn't work. Not only that but my root node isn't working either.
    I'll post some code here and hopefully someone knows what I'm doing wrong.
    package avlTree;
    * @author 383259
    public class AVLTree extends BinaryTree
         private int size;
         private BSTNode root;
         private String side;
         public AVLTree()
              super();
          * @param element
         public AVLTree(Comparable element)
              super(element);
          * @param element
          * @param left
          * @param right
         public AVLTree(Comparable element, BSTNode left, BSTNode right)
              super(element, left, right);
          * @param element
          * @param left
          * @param right
         public AVLTree(Comparable element, BinaryTree left, BinaryTree right)
              super(element, left, right);
    private BSTNode addToTree(Comparable o)
              try
                   boolean status = false;
                   if(isEmpty())
                        System.out.println("yes");
                        status = true;
                        root = new BSTNode(o);
                        size++;
                        setRoot(root);
                        return root;
                   else
                        System.out.println("yes");
                        BSTNode currNode = root;
                        BSTNode newNode = new BSTNode(o);
                        while (status == false)
                             if(newNode.compareTo(currNode.getElement()) == 1)
                                  if (currNode.getRight() == null)
                                       currNode.setRight(newNode);
                                       newNode.setParent(currNode);
                                       size++;
                                       side = "right";
                                       status = true;
                                       return newNode;
                                  else
                                       currNode = currNode.getRight();
                             else if(newNode.compareTo(currNode.getElement()) == -1)
                                  if (currNode.getLeft() == null)
                                       currNode.setLeft(newNode);
                                       newNode.setParent(currNode);
                                       size++;
                                       side = "left";
                                       status = true;
                                       return newNode;
                                  else
                                       currNode = currNode.getLeft();
                             else
                                  status = true;
                                  return null;
                        return null;
                   catch (ClassCastException cce)
                        return null;
                   catch (NullPointerException npe)
                        return null;
                   catch (IllegalArgumentException iae)
                        return null;
         }That private, addToTree method is actually the same as the add method in the binary tree, but is only a small part of the add method in the AVLTree. Anyway, my private root node attribute and size attribute aren't updating for some reason or another, and I cannot figure out why.

    So, I made the BinaryTree class abstract,And you did that why exactly?
    So I thought that by doing this all I had to do was
    put in the add method and change the code and then I
    could use all the methods in the BinaryTree class. Which is correct. Minus the private stuff, as you found out. That's what private means, after all.
    Well it seems that I can, except that none of it
    works correctly because of private attributes. For
    example, my size doesn't update in my new add method
    and I can't figure out why. I have a private int size
    in both classes but it doesn't work. Not only that
    but my root node isn't working either.I guess it doesn't work because you now have two size variables and constantly use the wrong one. Make size protected, or better, provide a protected setter for the size. Do the same for other private attributes you need to access.

  • How does a method extend another method in the same class ??

    hi everybody, I want to know if it is possible to have such code as:
    void foo(){
    // foo process
    void bar <<extend>> foo{
    //foo process
    //bar process
    thanks for helping me

    Since you want different names for each of your so-called "child" methods, then neither overloading nor overriding in a subclass will work as each relies on the same method names. Perhaps the following will suffice:
    public class MyClass
       //some stuff
       private myMethodThatDoesSomeStuff()
          //do some stuff that all the other methods must also do
       private methodA(int q, byte z)
          myMethodThatDoesSomeStuff();
          // continue with this method.
       private methodL(short v, float g23)
          myMethodThatDoesSomeStuff();
          // continue with this method.
    }If not, you need to do some design work.

  • Can extends keyword be used with respect to interfaces?

    can extends keyword be used with respect to interfaces?

    srinu269 wrote:
    can extends keyword be used with respect to interfaces?Yes. An interface can extend another interface:
    interface A {
        public void a();
    interface B extends A {
        public void b();
    class X implements B {
        public void b() {    
        public void a() {
    }

  • Workbench problem when interface extends interface

    Hi,
    I have a problem when importing an existing class into Toplink Workbench. This class has a getter/setter on a property, say getAccountType() where AccountType is an interface. This property is not persistent, only a string representation of its value stored in a private field. So as far as Toplink is concerned, the interface AccountType is not persistent.
    When I try to import, I get an ExternalClassNotFoundException. We found that the interface AccountType extends another interface and this seems to be the problem. If we remove the inheritance, the import goes fine.
    I don't know if this is related, but AccountType is in my project and the super-interface is in a dependency jar file (this jar file is specified in workbench's CLASSPATH).
    workbench = 9.0.4.2
    jdk = 1.4.2_07
    Thanks for your help
    Jean-Christian Gagne

    Unfortunately in 9.0.4, the error message you are receiving is not very helpful or accurate. My guess is that something the super-interface is referencing is not on your classpath and that is why you are getting the exception. In 10.1.3 this will not be a problem because we have changed how we load classes. Your super-interface would not actually be loaded in to the workbench.
    Karen

  • Extends thread and Runnle Interface

    In java there 2 ways to create thread
    1.Extending thread
    2.implements runnable interface
    What is difference between the 2 approaches? which one to use where?

    public class ThreadTest extends Thread {
      public void run() {
      public static void main(String[] args) {
        ThreadTest tt = new ThreadTest();
        tt.start();
    public class ThreadTest extends Runnable {
      public void run() {
      public static void main(String[] args) {
        ThreadTest tt = new ThreadTest();
        Thread t = new Thread(tt);
        t.start();
    }The difference is how you start the thread when you code it. if you extend Thread, you can call its run method directly. When you extends Runnable, A wrapper is needed to start the thread.
    The Runnable approach is used when your class is extending another class (eg. JFrame). Since Java do not support multiple inheritance, you can write something like public class MyProg extends JFrame implements Runnable, and still have a thread.

  • Implements interface method at the derived class

    Hi all.
    I have a class (Derived) that extends another class (Base).
    In the base class (Base) there is a method f() with its implementation.
    In the interface (C) there is also f() method exactlly like in the base class (Base).
    The derived class (Derived) is implements the interface (C).
    My question is:
    Do i have to implement the method f() in the derived class (Derived) ?

    My guess is that you probably have to, even if it's just to call the parent's method.
    This all sounds pretty sketchy. Why don't you just make the BASE class implement your interface?

  • Class constructor that implements an interface returns an  "interface", why

    Hi,
    I am studying some code that I need to understand well. This code works, I just don't understand the following:
    A class was defined extending an interface as so:
    public class GeometricShape implements Area {
    // constructor
    public GeometricShape() {
    System.out.println('bla);
    In another file, GeometricShape class was instantiated as follows:
    public class ExampleUse {
    Area g = new GeometricShape();
    My qustion is, why does the code above expects "new GeometricShape()" constructor to return an interface of type Area?
    Can someone explain?
    thanks

    Can someone explain?When a class implements an interface, or extends another class, or when a interface extends another interface, it means that anywhere an instance of the parent class or interface is expected, the child can be used.
    Wherever a Mammal is expected, you can provide a Dog or Cat or Whale or Human or NakedMoleRat. Each of those is a mammal.
    If you say "give me some food," and you don't specify anything else, the person you're talking to can hand you a hamburger or an apple or a bowl of rice. Any of those will meet the requirements you put forth.
    This is how the OO "is-a" relationship maps to Java.

Maybe you are looking for

  • How to delete books (epub) off your Itunes library

    I'd like to remove some books from my Itunes library to make syncing with my Ipad easier. Some of the books are duplicates or (after reading) are not something I'd ever read again, so I'd like to delete them from the Itunes library. I can't seem to f

  • Remove Header when running report with ALV output

    Hi, We are running ITS Version 6200.1022.63326.3, Build 84960 connecting to R/3 Enterprise 4.7 on 6.40 Kernel Patch 196. I have a situation where I run a report through ITS, starting with a selection screen, I can remove the header part of the ITS ge

  • SAP ARCHIVING

    DEAR ALL, what does the below mean? "maintain account type file"? "maintain document type file"? must this be done always before archiving? Configuration In SARA tcode, Object : FI_DOCUMNT (For archive FI Documents) and press enter click on customizi

  • Busy message...

    Whenever I call my contacts Skype to go number, the automated voice recording states that the contact is busy and to try again later. This happens every time. Especially when she is not busy. She has no problem calling my cell, I find it hard to unde

  • I'm having problems installing adobe flash player on my computer

    I USED MOZILLA FIREFOX, AND INTERNET EXPLORER AND TRY INSTALLING ON GOOGLE .COM AND WILL NOT INSTALL ON WINDOW XP