Confusion with interfaces

Hi ,
What is the advantage over using interface. I mean , suppose
public interface Calculator
int add();
int sub();
int div();
int mul();
Now
public class Calculation implements Calculator
// will implement all method of Calculator interface
The same thing i can achieve with abstract class.

Prem wrote:
What is the advantage over using interface. I mean , suppose Well a Google of "advantages of using interfaces" threw up [url http://artofsoftwarereuse.com/2010/04/24/5-advantages-of-using-interfaces-for-reusable-assets/]this page, which gives 5 pretty good ones.
...The same thing i can achieve with abstract class.Yes, but an abstract class imposes a hierarchy that may not be desirable (hopefully, you've already been warned about overusing inheritance); it also (usually) imposes an implementation which may not be suitable for everyone.
PS: Didn't you already ask this question?
I believe I suggested you look at AbstractList as an example of a good pattern for an abstract class (ie, as a skeleton implementation of an interface).
Winston

Similar Messages

  • I am confused with Interface

    my example is
    public interface IName
    public interface IAdress
    public interface IPhoneBook
    public class PhoneBook implement IPhoneBook
    my question is
    IPhoneBook associate with IName interface at the one time. (public interface IPhoneBook extends IName) ex.
    But IPhoneBook must be have one more with IAdrress (like. BillingAddress, ContactAddres).
    How code IPhoneBook
    and How PhoneBook create java code...

    if you have a good solution my PhoneBook class can
    you send to me class and Interface codes.You don't have to start using interfaces from day
    one. Why don't you just define a plain PhoneBook
    class holding information about name, address and
    phone number?because hibernate need Interface for caching..What's hibernate? And why does it need exactly a interfaces? And why especially for cashing? What cashing?
    Are these interfaces predefined? In that case you only have to implement them. Is your question actually how one implements an interface?

  • Socket Programing in J2ME - Confused with Sun Sample Code

    Hai Everybody,
    I have confused with sample code provided by Sun Inc , for the demo of socket programming in J2ME. I found the code in the API specification of J2ME. The code look like :-
    // Create the server listening socket for port 1234
    ServerSocketConnection scn =(ServerSocketConnection) Connector.open("socket://:1234");
    where Connector.open() method return an interface Connection which is the base interface of ServerSocketConnection. I have confused with this line , is it is possible to cast base class object to the derived class object?
    Plese help me in this regards
    Thanks in advance
    Sulfikkar

    There is nothing to be confused about. The Connector factory creates an implementation of one of the extentions of the Connection interface and returns it.
    For a serversocket "socket://<port>" it will return an implementation of the ServerSocketConnection interface. You don't need to know what the implementation looks like. You'll only need to cast the Connection to a ServerSocketConnection .

  • TS1702 I had this Scrabble on my iPad2 and began to have connection problems, it would lock in the "connecting" position. This is not the first time Scrabble has had problems with interface. Typically customers delete the Ap then download it again to rein

    I have contacted EA about this and can find no help. I had this Scrabble on my iPad2 and began to have connection problems, it would lock in the "connecting" position. This is not the first time Scrabble has had problems with interface. Typically customers delete the Ap then download it again to reinstall it. During the process you sign in and approve the purchase KNOWING that another window will open saying that you have previously purchased it and that there is no charge. So what happened this time? It will not connect and all of my saved and current games are wiped out. I want my money back, this game interface is pretty junk and operates like some ancient DOS program,,bug,bug,buggy. I want my money back.

    Go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • Incompatible with interface - Exception in Adapter Module

    Hi Experts,
    I have a custom adapter module deployed on PI 7.1. Once i post any message, i am getting below exception in CC monitoring.
    Message processing failed. Cause: java.lang.ClassCastException: class $Proxy3125_10002:sap.com/ClearModule_EAR @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 6daa7537 @ alive incompatible with interface com.sap.aii.af.lib.mp.module.ModuleLocal:library:com.sap.aii.af.lib @ com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 15d75e80 @ alive
    I used NWDS 7.1 to develop the module.
    the EJB is stateless.
    Can any one have any idea about the exception.
    Please help me out here.
    Thx in advance,
    Brian

    Hello,
    i forgot to modify the four interfaces' name when i create the EJB, ie my Bean class is "ss.cod.de.EjdBean", then the "Remote Interface" & "Home Interface" are setted respectively and defaultly as "ss.cod.de.EjdRemote" & u201Css.cod.de.EjdHomeu201D, the u201CLocal Interfaceu201D & "LocalHome Interface" are the same to the two interface above.
    everything was well while i rectified all the interfaces as "com.sap.aii.af.lib.mp.module.ModuleHome", "com.sap.aii.af.lib.mp.module.ModuleLocal", "com.sap.aii.af.lib.mp.module.ModuleLocalHome" and "com.sap.aii.af.lib.mp.module.ModuleRemote".
    hope its help 4 u.
    good luck.
    thx & br,
    Brian

  • Need help with interface development

    Hi i need help with requirement below with developing interface between or online order system and sap plz lemme know what is bapi i use for creating customer, update and assigining partner id to costumer.
    SAP Development
    1.     Using standards SAP functional module (with BAPI), create interface that will create/change Ordering party customer in SAP. Following fields are mandatory for customer creation:
    •     MANDT     Client
    •     VKORG     Sales organization
    •     VTWEG     Distribution Channel
    •     SPART     Division
    •     KDGRP     Customer Group (= “ZORP)
    •     KUNNR     Customer number
    •     NAME1     Name 1
    •     NAME 2     Name 2 (if required)
    •     SORTL     Search term (short description)
    •     ZZALTKN     Search term 2 (old customer number)
    •     LAND1     Country
    •     ORT01     City
    •     PSTLZ      Zip Code
    •     REGIO      Region (state in USA)
    •     STRAS     Street
    •     TELF1     Primary telephone number
    •     TELFX     Primary Fax number
    •     ZZPRPLANS     Payment Plan
    •     CCINS     Payment card: Card type
    •     CCNUM     Payment cards: Card number
    •     CCDEF     Payment Card: Default Card Indicator
    •     ZBDGID     Customer Budget ID
    •     ZHOLD     Budget Hold indicator
    •     ZZCOSTCENT     Cost Center
    2.     Upon successful customer creation system will issues “S” (success) message that customer has been created.
    3.     New ordering party customer created in step ½, will have to be assigned as new partner to its belonging Sold-to/Ship-to customer. Use standard SAP customer functional module in order to perform this partner ID assignment. Partner ID for ordering party should be “ZO”.
    1.7     Enhancement Functionality
    Apart from creating a new interface to do the required functionality, the Order Create Interface also has to be changed to accommodate a field to pass the Ordering Party Number on the Order. The technicalities of how we are going to implement the interface will be laid out in the Tech Specs.
    Thanks
    in advance

    You have double posted, please mark this one as "solved on my own" and refer to this thread
    need help with interface development
    Regards,
    Rich Heilman

  • New bug in 8.02 - regions confused with each other

    So, I just updated to 8.02, and loaded up a recent project that was half finished (bad idea).
    Now I have some strange bugs going on that I never had before, and they are basic issues.
    My audio regions keep getting confused with each other.
    I have an audio region that I can't open in the sample editor. When I double click on it, the sample editor will bring up the last region I edited, not the new one. I've re-named the region, deleted it and re-added it to the arrange window, but this region will not open in the sample editor.
    I can see it in my media bin, and preview it there, and it plays in my arrangement no problem, but I can't get it to open in the sample editor. In fact sometimes when I click on it, with the media window open, I can see another sample being 'selected' in the media window instead of the proper audio region.
    Scott

    finally i find someone else with the same prob, o already post into apple.com too
    yes here the same, bug new in 8.0.1, cause on logic 8.0.0 all works fine (except some click noise when you pre-listen a file in autoloop)
    however here what i can say to you (it's 3 days i'm studyng this cause i make a massive use of ultrabeat)
    - no matter both power pc / intel soffer of this bug
    - i try to update to leopard from my 10.4.11 (same bug) tryin a new os installation (same bug), tryn without audio card and driver (same bug)
    so i really don't know how to solve it, cause there are only few people that have this problem
    big mistake and big mistery

  • Problem with interfaces

    Greetings everyone!!! Todays' question has to do with interfaces. Anyone who might be able to help is welcomed!!!
    This is my main, which constracts new object of the type Rectangle and employee and tries to find the average and the maximum area and salary accordingly
    import java.awt.Rectangle;
    public class DataSetTester
         public static void main(String[] args)
              Measurer m = new RectangleMeasurer();
              DataSet data = new DataSet(m);
              data.add(new Rectangle(5,10,20,30));
              data.add(new Rectangle(10,20,30,40));
              data.add(new Rectangle(20,30,5,10));
              System.out.println("Average area = " + data.getAverage());
              Rectangle max = (Rectangle) data.getMaximum();
              System.out.println("Max area Rectangle = " + max);
                                    Measurer x = new EmployeeMeasurer();
              DataSet data1 = new DataSet(x);
              data1.add(new employee("Mike", 1500,10));
              data1.add(new employee("fgh",2000,10));
              employee max1 = (employee) data.getMaximum();
              System.out.println("Max employee = " + max);
    }This is the DataSet class which provides the methods to find the average and the maximum
    public class DataSet
         public DataSet(Measurer aMeasurer)
              sum = 0;
              count = 0;
              maximum = null;
              measurer = aMeasurer;
         public void add(Object x)
              sum = sum + measurer.measure(x);
              if(count == 0 || measurer.measure(maximum) < measurer.measure(x))
                   maximum = x;
              count++;
         public double getAverage()
              if(count == 0)
                   return 0;
              else
                   return sum / count;
         public Object getMaximum()
              return maximum;
         private double sum;
         private Object maximum;
         private int count;
         private Measurer measurer;
    }This is my interface
    public interface Measurer
         double measure(Object anObject);
    }The classes that implement the interface
    import java.awt.Rectangle;
    public class RectangleMeasurer implements Measurer
         public double measure(Object anObject)
              Rectangle aRectangle = (Rectangle) anObject;
              double area = aRectangle.getWidth() * aRectangle.getHeight();
              return area;
    public class EmployeeMeasurer implements Measurer
         public double measure(Object anObject)
              employee anemployee = (employee) anObject;
              double payment = anemployee.getsalary() * anemployee.getmonths();
              return payment;
    }And the class employee
    public class employee
         private String name;
         private double salary;
         private double months;
         public employee()
              name = "";
              salary = 0;
              months = 0;
         public employee(String newName, double newSalary, double newMonths)
              name = newName;
              salary = newSalary;
              months = newMonths;
         public String getname()
              return name;
         public double getsalary()
              return salary;
         public double getmonths()
              return months;
    }Everything compiles but when I execute I get the desired results for the rectangle class(average and maximum)
    , but it does not work for employee.
    I get: Exception in thread main java.lang.ClassCastException: java.awt.Rectangle
    at DataSetTester.main(DataSetTester.java:18)
    Edited by: mixalissen on 26 ??? 2008 10:29 ??

    max,
    What you are constructing is called a "dirty" collection... as the negative connotation suggests, that isn't the recommended practice.
    The recommended practice is to treat "disparate things" as distinct types... and if you require collections of those things then you create two individual and distinct collections.
    However, in your example, Employee and Rectangle have "behavior in common" so you can (even if it doesn't make a lot of sense in "the real world") create an interface, which (among other things) allows you to create a collection of the-type-of-that-interface.
    So your DataSet should contain Measurable 's (note: not Measurer's)... and Rectangle and Employee should both implement Measurable (hint: think Rectangle is Measurable; not Rectangle is a Measurer; and never RectangleMeasurer (yuck))... and then of course you'll need to move the appropriate measure method to Rectangle and Employee.
    Cheers. Keith.

  • Confused with document life & account life

    I have a doubt regarding archiving
    I think in archiving projects especially for finance module
    there are lot of customization settings to be done form the functional side before Archiving , for example Document life ,Account life... etc
    I have a doubt weather those customization settings needs to be carried out by archiving consultant or
    the FI functional consultant?
    Can any one tell what is the difference between Secondary indexes and Archive Indexes in FI ?
    i am  really confused with the Archiving projects..... can any one help me
    Moderator message: not related to ABAP development, please post again in the appropriate SDN forum, always search for available information before asking.
    locked by: Thomas Zloch on Sep 23, 2010 11:41 AM

    Patience is a virtue.
    Rob

  • Confused with HD-SD

    Hi,
    All the sudden I am confused with my searches on this forum and would appreciate clarification
    I am presently working on a HD project (from HD clips and HD stills).
    If I want to get the best out of it, should I use only BluRay burning or would it be OK to use HD setting and burning with DVDSP on a "regular" DL disk (the compressed project will be over 7 GB ?
    Should I understand that if I use HD setting with DLdisks only a HD compatible DVD player will be requested ?
    will a Bluray player play the HD-DL fine ? or will a bluray disk be requested on bluray player ?
    As you can see I just got really confused ...
    Thanks in advance
    Ivan

    No doubt this stuff can be confusing. Hopefully I'll be able to clear a few things up.
    You shot and edit an HD project in HD. Now you would like to create a DVD correct?
    You have 2 options for DVD
    1. Standard Definition DVD authored in DVDSP.
    2. Blu-Ray DVD. You'll have to purchase a burner.
    If you are on the newest FCS then you can author and burn a Blu-Ray DVD inside of Compressor. If you are on the previous version then you need another application to author and burn Blu-Ray like Toast or Adobe Encore.
    You made mention of HD-DVD. That format is dead and won't play on anything other than your Mac or a couple specific HD-DVD players that haven't been in production for years. If you look in the DVDSP preferences you can choose which kind of DVD to burn SD-DVD or HD-DVD. Choose SD whenever you are using DVDSP.
    Blu-Ray players play Blu-Ray DVD's and SD DVD's. It will not play HD-DVD.
    How long is your project if the compressed (m2v) files are coming in at over 7GB?

  • SS9 CC5.6 compiler bug - algorithm count confused with struct member

    Found some code that fails to compile in CC 5.6
    CC: Sun C++ 5.6 2004/07/15
    #include <algorithm>
    using namespace std;
    struct A {
      int count;   
    struct B
      struct A *a;
    int main(int argc, char **argv)
      struct B *b = 0;
      // This line fails to build, any other operator is ok
      if ( b->a->count < 50 )
      return (1);
    }Fails with error :
    "c56_algorithm_bug.cpp", line 21: Error: Unexpected ")" -- Check for matching parenthesis.
    "c56_algorithm_bug.cpp", line 22: Error: "," expected instead of "{".
    "c56_algorithm_bug.cpp", line 22: Error: Illegal value for template parameter.
    "c56_algorithm_bug.cpp", line 22: Error: ")" expected instead of "{".
    4 Error(s) detected.The compiler is getting confused with the use of the count struct member vs the count algorithm. Changing the < to a > fixes the problem.
    Using CC5.3 works fine as well as all other compilers we use (gcc 3.4, mipspro 7.4, VC 7.1)
    Anyone seen this ?
    - mark

    This bug has been fixed in the C++ 5.6 compiler. I'm not sure if the fix is in the first patch which is about to be released. If not, the fix definitely will be in the next patch.
    The workaround is not to use
    using namespace std;That using-declaration is a pretty big hammer, and often results in conflicts with user code, compiler bugs aside.

  • Can we create objects with interface

    can we create objects with interface,if yes then where we implement the
    methods,can we type cast any object with inerface kind of object,if yes what kind
    of objects we can type cast

    can we create objects with interface,if yes then where we implement the
    methods
    Objects are created with classes, not interfaces, which are abstract.
    can we type cast any object with inerface kind of object,if yes what kind
    of objects we can type cast
    Objects may be cast to interfaces, but only if an object's class or one of its superclasses actually implements the interface.

  • Again confused with delta update.

    Hello experts
    I am confused with delta update as usual
    I have one Infocube in which last data pull was on 29.11.2005.
    If now again I run delta load then will it pull entire data from 2005 to 2008 or I should delete all data from cube n do full load??
    Kindly explain
    Regards
    Swati

    Hi Swathi
    LIS EXTRACTION
    T.code - :MC18 – create field catalog
    1. Characteristic Catalog
    Application-01-Sales and Distribution, 02-Purchasing, 03-Inventory
    Controlling, etc..
    Catalog category 1. Characteristic catalog, 2. Key figures catalog 3.
    Date catalog
    Select characteristic catalog and enter, click on characteristic select
    the source table and it will be display the relevant source field and
    select the source field, copy + close, copy.
    Save, similarly create key figures catalog
    T.code : MC21 – create infostructure
    Example –
    Inforstructure : S789
    Application – 01
    Choose characteristic select the catalog, select the fields, copy +
    close
    Choose key figures catalog select the key figures ,copy + close, save
    and generate
    T.code – MC24 – create updating
    Infostructure : S789
    Update group : 01- Sales document, delivery, billing document ,enter
    Select the key figures click on rules for key figures give suggest
    rules, copy save and generate
    Click on updating (activate updating)
    Select the infostructure set periodic split 1. Daily, 2. Week, 3.
    Month, 4. Posting period
    Updating –1)No updating,2)Synchronous updating (V1), 3)As synchronous
    updating (V2), 4)As synchronous updating (V3),
    T.code – LBW0 - Connection of LIS Information structures to SAPBW
    Information structure : S786
    Select the radio button-Setup LIS environment and Execute.
    Select the radio button-Generate data source and Execute.
    For Delta update:
    Select the radio button-Generate updating and Execute
    Select the radio button -Activate / deactivate and Execute.
    T.code – SBIW – Display IMG (implementation guide)
    Setting for applications specific data source – logistics – Managing
    transfer information structure – setup of statistical data – applications
    specific setup of statistical data –perform statistical setup – sales.
    Choose activity
    Setup – Orders, deliveries, billing
    Choose the activities enter the infostructure (S789), give name of the
    run, date of termination, time of termination, No. of tolerated faulty
    documents. Then execute
    T.code – RSA3 – Extractor checker
    Give the data source name eg. 2LIS 01S789 and execute, result will
    get some records
    Go to BW side replicate data source – Assign infosource – Create
    infocube – Create update rules – create infopackage and schedule the package
    with initialize delta process.
    For delta update :
    In R/3 side
    T.code – MC25, set update (V1) or (V2) or (V3)
    T.code – LBW0, choose generate updating and execute then choose
    activate / deactivate and execute
    BW side - create infopackage and schedule the package with delta
    update.
    First time if your scheduling the infopackage -in R/3 side T.code :MC25
    -Udating set to No update,insted of selecting the update V1,V2,V3.
    If your doing the Delta update:in R/3 side T.code :MC25-Updating set to
    either V1 or V2 or V3. and the to T.code :LBW0 -Select the radio button
    Active/deactivate and Execute.
    and schedule the infopackage with delta update.
    Regards,
    Chandu.

  • I purchased an IPAD2 for my special needs daughter.  She only currently understands lowercase letters only and gets confused with the uppercase letters.  Is there a way to change the keyboard to display lowercase letters?

    I purchased an IPAD2 for my special needs daughter.  She only currently understands lowercase letters only and gets confused with the uppercase letters.  Is there a way to change the keyboard to display lowercase letters?

    There is no way for the keyboard itself to display only lower case letters. It doesn't display lower case letters at all for that matter.
    When you are using the keyboard - The other issue that you will have is with the shift key. Even with auto caps turned off you can still type capital letters if you tap the shift key and if you double tap it by mistake - it will turn into all capital letters so also turn off Caps Lock in the keyboard settings.
    Other than that, there is no way to ensure that you can type in lower case.
    Maybe an external bluetooth keyboard would be a better solution but I don't use one, and I have never even seen one in person so someone else will have to verify that for you.

  • Confusing with AddJavaFile in jdev.conf

    I am confusing with the format in AddJavaFile in jdev.conf:
    for example:
    AddJavaLibFile ../../BC4J/lib/bc4juixtags.jar
    AddJavaLibFile ../lib/batik-xml.jar
    their absolute paths respectively are:
    /usr/jdeveloper/
    /usr/jdeveloper/jdev/
    could anybody give me some help?
    Thanks a lot!
    Peter

    sorry for my unclear question.
    my installation is <jdev_root> = /usr/jdeveloper/
    From the file, I got:
    AddJavaFile ../../BC4J/lib/bc4juixtags.jar
    it seems to me it equals : jdeveloper/jdev/BC4J/lib/bc4juixtags.jarActually it should be:
    /usr/jdeveloper/BC4J/lib/bc4juixtags.jar
    and not:
    /usr/jdeveloper/jdev/BC4J/lib/bc4juixtags.jar
    another line is:
    AddJavaFile ../lib/batik-xml.jar
    it seems to me it equals : jdev/lib/batil-xml.jarCorrect.
    there is unconsistency here (I may be wrong)Actually it is consistent. The jdev.conf file contains pointers to where JDev can find other components which it depends on. In the two cases which you point out, the first is part of the RT layer of BC4J (which is also shipped in iAS) and the second is the batik XML parser from Apache.

Maybe you are looking for

  • Report Issue - Vendor payment's according to GL Account

    Hi, We want to develop a report, which shows Amount Paid to Vendor in behalf of Sub-contractor's GL Account...format like.. GL Account...............Business Area........Vendor...............Month............Amount Paid Is there any standard report,

  • Users Opening to Their Dektop

    RDS 2012 publishing office to users desktop. Our users are not using thin clients. They have their own desktop PC with their own local profile. What is everyone else doing for when users file->open in an office app and the user is seeing their profil

  • Unable to create xml from xml schema

    JDeveloper 10.1.3 EA1 I am unable to create a new xml file from an xml schema when the starting root element is a complex type (but it works with a simple type). It does not matter if the xml schema is registered within JDeveloper. Is this a bug or i

  • Need All Three Topics To Be Links

    Hi, I have a webpage where I'm displaying the top three topics dscussed on the site, the way i want this set up is like this, to have the topics displayed on the page as a link to the secetion on the site where all the information on that topic is lo

  • RE: memory utilization : more info

    Jeanne, Here is some stuff from experience and also (very importantly) the Advanced Application Dev course : 1. Sometimes with large objects particularly arrays within arrays, BLOBS and large windows the garbage collector can get inself into a knot.