Method in abstract interface

Suppose I have an abstract interface which has one method:
public abstract interface IParent {
  public void setSignal(int signal);
}And I have a concrete interface inherited from IParent which also have one method:
public interface IChild extends IParent {
  public void setSpeed(int speed);
}If I define a class which implements IChild it only asks me to implement setSpeed method.
public class Test implements IChild {
}Why it does not ask me to implement setSignal method of IParent interface?

Suppose I have an abstract interface which has one method:
Every interface is implicitly abstract.
public void setSignal(int signal);
Every method declaration in the body of an interface is implicitly public.
And I have a concrete interface inherited from IParent which also have one method:
Every interface is implicitly abstract.
If I define a class which implements IChild it only asks me to implement setSpeed method.'It' being what?
Why it does not ask me to implement setSignal method of IParent interface?I have no idea what 'it' you're talking about, but the Test class will not compile.

Similar Messages

  • About abstract interface and it's method

    Hi !!
    HttpSession session = request.getSession();
    getSession() is the Method of HttpSession and it is the abstract interface..
    right ??
    so how can we call the abstract method and ..
    here... request is the object of HttpServletRequest which is abstract interface so how can we make an Object of this abstract interface...
    I m very confused Please solve my Querry ASAP

    As far as I can tell, these three threads are all the same person asking the same question.
    http://forum.java.sun.com/thread.jspa?threadID=5188609
    http://forum.java.sun.com/thread.jspa?threadID=5188638
    http://forum.java.sun.com/thread.jspa?threadID=5188603
    How obnoxious.

  • Use of abstract interface

    I have a series of questions....... Go through.
    What is the use of abstract interface in java ?
    What is the use of static object in java ?
    What is the use of abstract key word to variables ?
    Object reference passed to method are final. Can ' t we change it ?

    class Testing {
         int i;
    public class RefFinal {
       public static void f ( Testing t1, Testing t2) {
           Testing temp;
           temp=t1;
           t1=t2;
           t2=temp;
           System.out.println("value of i in t1 =" +t1.i);
           System.out.println("value of i in t2 =" +t2.i);
       public static void main( String args[]) {
          Testing t1 = new Testing();    
          Testing t2 = new Testing();    
          t1.i=10;
          t2.i=20;
          f(t1,t2); 
          System.out.println("value of i in t1 =" +t1.i);
          System.out.println("value of i in t2 =" +t2.i);
    }      Here the code explain why?

  • Public abstract interface FilterConfig

    public abstract interface FilterConfig
    what is this class actually . is it abstract class or interface?

    An interface is always totally abstract ???Yes, all methods of an interface can be declared abstract but you don't have to because that's understood. An interface can carry no implementation. It contains only abstract methods and static variables. Also everything is automatically public so you don't have to point that out specifically.

  • Public abstract interface I{

    Interface are totally abstract by default so what is the need of abstract in
    public abstract interface I{
    ........}does this have any functionality........

    I believe it's entirely redundant.
    I believe that the "public" part is also entirely
    redundant.
    Check the language spec to be sure.Abstract is redundant--all interfaces and their methods are implicitly abstract.
    Public is redundant for interface methods--they're always public--but not for the interface itself. You can have package-scope interfaces. Not sure about private ones.

  • Abstract Interface in XI

    Hi Experts,
    Is the concept of Abstract Interface same as that of Java?
    I know that the abstract interface is used in BPM and it doesnt have any direction. Any special use of abstract??
    Please suggest.
    Regards,
    Sushama

    Hi Sushma,
    When you're defining an interface in Java, it's always abstract, though you
    don't need to declare them as such.
    So there's no difference between
    abstract interface I
    void method();
    ....and...
    interface I
    void method();
    I think
    but abstract interfaces in XI are different for Java abstract.
    Thanks,
    Sateesh

  • Getting return value of a method in an interface

    Hello! I have a problem. I have an interface called I. One of the declared method in this interface is M. And I have a class called C. Class C declares Interface I. I want to get the return value of the method M. I used invoke method. M.invoke(anInstance, arg[]). You can't take the instance of interfaces or abstract classes. If I use a class instead of instance for anInstance variable, i get "java.lang.IllegalArgumentException: object is not an instance of declaring class" error. If I use an instance, i get "java.lang.IllegalAccessException: Can not call newInstance() on the Class for java.lang.Class" error. This is because of getting an instance of an interface. if you can help me. i will be greatfully happy.

    Thanks for the feedback Tom although you should rethink what you said.
    I did not trash your suggestion, nor did I make any reference to it.
    Perhaps you should read the OP to see where you went wrong.
    OP wants to know return type of Interface's methodNo, the OP wants to obtain the return value.
    AND OP knows that instantiation won't work.He was trying to instantiate an Interface, which is not possible. In order for him invoke a Method he needs a concrete implementation. I was simply pointing out what he needs to do in order to acheive his aim.
    b) there may be no known implementing classes at
    runtimeIf there is no implementing class provided then he will not be able to invoke a method on its instance.
    c) even if there were such a class, instantiating it
    may have unwanted side effects, takes unnecessary
    timeWhy is that a problem? One reason for invoking M is to see what happens.
    the class may have N methods while the interface
    has only one, so you might look for the correct method
    too longIf you bothered to study the code I supplied I obtain a Method from the Interface class so there is no problem in "looking" for a method, besides which there can be exactly 1 method with a given signature in any class so there is no searching involved.
    On a personal note, such negative replies are neither helpful to the OP and can cause a credibility problem caused by being labelled a Troll.

  • Internal class implementing interface extending abstract interface :P

    Confused ha? Yeah me too. RIght here it goes.
    Theres an abstract interface (abstractIFace) that has for example method1() method2() and method3(). There are two other interfaces iFace1 and iFace2 that extend abstractIFace. Still with me? :P iFace1 only uses method2() whereas iFace2 uses method1(), method2() and method3(). Internal classes implementing these are then used. The reason is so that when returning an object one method can be used that will return different types of objects. But this doesnt work. It says that all the classes in the abstractIFace must be used/implemented but I only want method2() in iFace1 and all in iFace2.
    Just say what the f*ck if this is too confusing cos i think it is and i did a crap job explaining!! :P

    public interface IFace {
        void method1();
        void method2();
        void method3();
    public class Test {
        private static class Class1 implements IFace {
            public void method1() {
                System.out.println("method1");
            public void method2() {
                System.out.println("method2");
            public void method3() {
                System.out.println("method3");
        private static class Class2 implements IFace {
            public void method1() {
                throw new UnsupportedOperationException();
            public void method2() {
                System.out.println("method2");
            public void method3() {
                throw new UnsupportedOperationException();
        public static IFace createObject(boolean flag) {
            return flag ? (IFace) new Class1() : new Class2();
    }

  • Enforce static Singleton from Abstract/Interface??

    Hi,
    I'm trying to describe an interface IMyInterface which enforces all concrete subclass implementations to have a singleton "getInstance()" method whose method signature is always this "getInstance".
    So declaring the interface
    Interface IMyInterface{
    public IMyInterface getInstance();
    is fine, BUT in subclasses you can't override this method with a static class method.
    ie.
    public class X implements IMyInterface
    private static X instance=null;
    public static X getInstance()//ERR cannot override with static??
    if( instance==null)
    instance = new X()
    return instance;
    private X(){...}
    I thought about using an abstract superclass but this doesn't strictly enforce subclasses to implement their own singleton class-method.
    Why can't you override the method as a class-method?...and any ideas how to achieve this enforcement of the implementation of a singleton??

    If you have an abstract base class with the method
    public static Singleton getSingleton()  {
           return getSingletonImpl();
    }where getSingletonImpl is an abstract method
    protected abstract Singleton getSingletonImpl() ;This forces subclasses to provide an implmentation of the getSingletonImpl method.
    However you cannot guarentee that the returned Singleton is actually a singleton
    matfud

  • Why abstrace method exist in interface

    when I see junit source code .I see code about this:
    public interface Test {
          * Counts the number of test cases that will be run by this test.
         public abstract int countTestCases();
          * Runs a test and collects its result in a TestResult instance.
         public abstract void run(TestResult result);
    }I know that abstract method is for abstract class.But why it exist in this interface.

    All interface methods are abstract, even if you don't declare them as such, because they don't have implementation where they're declared.
    It's generally considered better form not to bother with "public" or "abstract" since they're redundant, but some people prefer to be explicit.

  • Java.lang.AssertionError: Can not find generic method public abstract

    I just downloaded the JDev 11g and trying to test the JEE web app. Below is my install:
    JDeveloper 11g
    JEE Web Project
    EJB 3.0
    Steps taken:
    1. Created an entity bean from a table.
    2. Created a session facade
    3. Create sample Java client to use the facade (Right-click on the session facade, and choose New sample Java Client from the context menu)
    4. Run the session facade
    5. Run the Java client
    I got the following error.
    java.lang.AssertionError: Can not find generic method public abstract java.util.List<com.oracle.orm.model.ejb.persistence.Hosttags> queryHosttagsFindAll() in EJB Object
    I checked the methods in the beans and interfaces, they are all there. Any idea?
    Thanks.

    I have a customer that has this problem.
    We wrote me that:
    we got a java.lang.NoSuchMethodException while the method exist even in the generated (by WLS) stub.
    when we change the interface by putting a "list" instead of list <> then it works.
    hope it can help, but should be great know why.
    Regards
    Marco
    글 수정: user10649412

  • Generic arguments in a Method on an interface.

    Hi all,
    I'm having trouble with the following code:
    Basically this is what i want:
    the Classes:
    public class SuperClass
    public class ClassA extends SuperClass
    public class ClassB extends SuperClass
    public class ClassC extends SuperClass
    The interface
    public interface interfaceX
       public methodX(SuperClass A);
    Implementation of the interface
    public class classX implements interfaceX
         public methodX(ClassA A)
    }My problem is on the declaration of the interface interfaceX in the class classX.
    How can i do such thing?
    I'm trying to avoid the "correct" declaration. this is:
    public methodX(SuperClass A)
            { ... }because I have a couple of class that extends that interface with deferents arguments, all of them extending from the SuperClass.
    I know i could use the instanceof keywork, but i'm trying to avoid the extra checking...
    Thanks in advance for any help!!
    Edited by: ValdemarP on Mar 29, 2010 1:55 AM

    i know I'm changing the contract, but only the arguments. if you notice, the new arguments is child of class SuperClass... How can I do this? Declare an method in an interface that accepts an arguments of some class and implement that interface, with argument that are children of the arguments declared in the interface... hope i was more clear this time... :(
    Example. I can do this on an interface:
    public void MethodListGeneric(List<? extends SuperClass> xpto )and during the implementation of the interface, I can declare the method using any arguments for the generic list, that extends SuperClass.
    Example:
    public class xpto extends InterfaceX
        public void MethodListGeneric(List<ClassA> xpto )
         // in here I've use ClassA insted of SuperClass
    }Edited by: ValdemarP on Mar 29, 2010 3:15 AM
    Edited by: ValdemarP on Mar 29, 2010 3:15 AM

  • Difference between abstract interface and normal interface

    Hello Friends,
    What is the Difference between abstract interface and normal interface?....

    What is the Difference between abstract interface and
    normal interface?....The difference is that you didn't follow convention in the first case. All interfaces are implicitly abstract so you don't have to declare them as such.

  • BPM, abstract interface unavailable

    Hello,
    I want to build a business process. Therefore I need some container elements. One container element has the type abstract interface. The message interface is defined in some namespace of some software component. But unfortunately I can't select this message interface in the dialog. Of course I have already activated my change list. I also refreshed the CPA cache, but this doesn't help a lot. What can I do in order to see this abstract interface.
    Thank you very much,
    Oliver

    Hallo Oliver,
    XI currently only allows BPM to use interfaces within the same software component or within a software component with which you have a based on relationship defined.
    I think, that this does not make too much sense, but that's the answer we got to an according OSS message.
    Best Regards
    Christine

  • How to create a method with an interface parameter?

    Hi there.
    I would create a method with an interface parameter. I mean this:
    public interface MyInt {
        public void method(int i);
    public class SubClass implements MyInt {
        public void method(int i) {
            System.out.println("The number is: " + i);
    public class MainClass {
        public MainClass(MyInt inter) {
            inter.method(10);
        public static void main(String[] args) {
    (*)     new MainClass(new SubClass());
    }I tried to compile this but do not work (incompatible types on (*)) . Is it possible to do something like that or not?

    I compiled and runned this code on my machine and it works fine.
    How did you did to compile and run this code ?
    Did you put each code on its own file or all codes in the same file ?
    I did like this:
    I put each code in its own file and put all in the same dir, after I did:
    javac -classpath . MainClass.java
    After that, I did:
    java -classpath . MainClass
    I hope this help you
    Lucas

Maybe you are looking for

  • Multiple databases in a single query

    I need to query multiple databases in a single query. e.g. Database d1 contains table t1 with column id Database d2 contains table t2 with column id I need a query like SELECT * FROM t1, t2 WHERE t1.id = t2.id; is this possible in jdbc? if yes can an

  • Hard Drive Compatible for Mac And Windows

    This is a strange problem, and I cannot find a solution. I just built a PC with a 300gb drive for just installing programs. I also bought a 500gb internal for storage of music, movies, pictures. I want the 500gb to be able to be accessed over the net

  • SQL Server detected a logical consistency-based I/O error

    Dear all, Please suggest me the solution of following error 1). [Microsoft][SQL Native Client][SQL Server]SQL Server detected a logical consistency-based I/O error: torn page  '' (SEVT) (expected signature: 0x0; actual signature: 0x4104104). It occur

  • Adrci - SHORTP_POLICY does not remove Trace Metadata files (.trm)

    how to remove the old Trace Metadata files (.trm) using just adrci in unix , database is 11g R2? Seemls like after when I changed the SHORTP_POLICY it does remove .trc files but I still have a lot of old .trm files that goes to . . . 2010;

  • Error flash player 10

    I keep getting flash payer 10 errors when loading flash games from the imtetrnet.