Could Someone Explain Interfaces in English Please?

Hi Everyone-
I'm new to Java. I've been reading "Learning Java" from O'Reilly. From what I understand, Interfaces are sort of a structural framework that lists certain methods. Any class that implements an interface must contain this "structure" and any objects intantiated using this class will be of the interface type? Is this correct? If not can someone explain interfaces in laymen's terms and the what is the usefulness of implementing Interfaces?
Thanks.
SA

I'm new to Java. I've been reading "Learning Java"
from O'Reilly. From what I understand, Interfaces are
sort of a structural framework that lists certain
methods. Any class that implements an interface must
contain this "structure" ...OK so far...
and any objects intantiated
using this class will be of the interface type? Is
this correct? It depends what you mean by "interface type". An interface can be said to define a type. So a class that implements that interface implements that type, and an object instantiated from that class is an instance of that type.
If not can someone explain interfaces in
laymen's terms and the what is the usefulness of
implementing Interfaces?The utility of interfaces is that, without being tied down to particular implementations, allows types of objects to be defined.
For example....is there a doctor in the house? Say:
1) a Doctor is:
- human
- has gone to medical school
- heals the sick
2) a Norwegian is:
- a person from Norway (assume we've defined "person" at this point)
3) a Canadian is:
- a person from Canada
So:
4) a Norwegian Doctor is a person from Norway who fulfills the qualifications to be a doctor
5) a Canadian Doctor is a person from Canada who fulfills the qualifications to be a doctor
6) a Canadian who is not a Canadian Doctor, is a person from Canada who does not fulfill the qualifications to be a doctor.
If your appendix is about to burst, you need a doctor. You don't care if the doctor is Canadian or Norwegian (assume everybody including yourself speaks Esperonto so there aren't any language issues). You do care deeply if the person trying to remove your appendix is a Canadian but not a Canadian doctor.
If you were establishing a hospital, you'd want doctors. If you were to write this in code, you'd have something like:
Hospital.hireDoctor(Doctor doc);meaning, that method in the Hospital class will hire a doctor, which is the important part. So this would work:
Doctor doc = NorwegianMedicalSchool.createDoctor();
Doctor doc_eh = CanadianMedicalSchool.createDoctor();
yourHospital.hireDoctor(doc);
yourHospital.hireDoctor(doc_eh);The point is, you can write your Hospital code without knowing precisely how "Doctor" is implemented -- whether the doctors come from Canada or Norway. You just write it as appropriate given that you have a Doctor. And then when a Doctor is created by a Japanese medical school, it doesn't break your code. This is why interfaces are said to define "contracts" -- an interface defines what something is (i.e., what it does), and you can make your code insist on getting something that does that (fulfills the contract).
Does this make any sense? Have I offended the Canadians? Probably.

Similar Messages

  • Could someone explain this to me, please?

    I fixed a problem without really understanding how and why the problem occured or even why my fix worked.  I'm hoping somebody can explain it to me.  Here's the problem:
    My form had this structure:
    MainSubform
         Page1Subform
              Subform1
              Subform2
              Subform3
         Page2Subform
              other subforms
         Page3Subform
              other subforms.
    There were other objects under the
    My application viewer, which is FormStream filler, was finding a fourth node under Page1Suform.  I couldn't access this phantom node in any way to find out any information about it, so any Javascript which navigated the hierarchy would error when it tried to reach it.
    Through a long consultation with other developers, I found that there was something called a 'bind match" node.  They couldn't explain it to me.  Not knowing what a 'bind match" node was, and figuring it had something to do with linking a data source to an object, I started checking the Default Binding tab in the Object Panel.  The Default Binding for Page1Subform was set to None, while the Default Binding for every other subform was set to Normal.  I set the Default Binding for Page1Subform to Normal and my problem disappeared.  I tried setting other Default Binding properties of other subforms to None to see what would happen, and the phantom node seemed to reappear and follow those subforms around.
    Can anybody give me an explanation of what was happening?

    Hi again,
    right so I have done what you all said and gone and read a book on LabView fundamentals, "introduction to data aquisition with LABVIEW by RH king"
    it has answered my questions about the for loop and most of the rest, the thing I am now having trouble with is the pink lines coming from the DAQ assistant, I have tried all the options, generate signal, aquire, sine wave, digital, continuous samples, N samples but I can't get a pink line, all I can get in that location is a gray "error out", is this all it is, just connect error out to error in.
    Also another thing that is confusing me is, just before the graph, that component between the last division and the graph indicator, I am having trouble identifying.
    Sorry to keep badgering on about this one but I need to get this example completed for work.

  • When running labview's test executive I recieve runtime error: Call to step "PRE-RUN" failed. Could someone explain this error?

    I have a set of vi's that work when run under labview. However, when calling these vi's from labview's test executive I recieve runtime error: Call to step "PRE-RUN" failed. in Assign Connector Pane.vi->Call Test.vi->Execute Pre-Run.vi->Test Executive. Could someone explain this error to me? (or ideally tell me how to fix it?) Thanks.

    Hello,
    There are any number of possible causes to this problem. Which version of Test Executive are you using? Have you upgraded your Test Executive recently? The latest version is 5.1.1. If you have changed anything about Test Executive on your computer recently, I recommend you perform a mass compile of all your VI libraries, as having different versions of the VIs on your system could often result in the "Call to Step XYZ Failed" errors. Also, are you using any DAQ or Analysis VIs in your steps? We have seen problems where the use of DAQ or Analysis VIs in the sequence can cause intermittent "Call to Step...Failed" errors. There are some KnowledgeBase entries on our website that discuss this problem. Are you using the Test Executive in the VI environment, or
    as an executable? Again, there are some problems with using Test Executive as an executable that result in these errors, and there are also KnowledgeBase entries that discuss these problems.
    If you have a pared-down application that demonstrates the problem, feel free to send me your VIs and your .seq file and I will try to reproduce the problem.
    Alternatively, I would suggest you visit www.ni.com/teststand to learn about TestStand, our state-of-the-art Test Sequencing software that completely outperforms Test Executive. It is very easy to use and much more powerful, and we have a top-notch support team available dedicated exclusively to supporting TestStand. As you are probably aware, we are no longer developing Test Executive, and instead are concentrating our efforts on making TestStand the penultimate solution for all our customers' test sequencing needs.
    I appreciate your patience on this issue. Please let me know if I can offer further assistance.
    Have a pleasant weeken
    d.
    Sincerely,
    Darren Nattinger
    Applications Engineer
    National Instruments
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Could someone explain the Factory Method Design Pattern

    Hi Experts.
    Could someone please explain for me the Factory Method Design Pattern. I read it a little and I understand that it is used in JDBC drivers but i'm not clear on it.
    Could someone explain.
    Thanks in advance
    stephen

    Basically, you have one class that's sole purpose is to create instances of a set of other classes.
    What will usually happen is you have a set of related classes that inherit from some base class. We'll say for example that you have a base class CAR and it has sub-classes FORD, GM, HONDA (sorry Crylser). Instead of having the user call the constructors for FORD, GM, and HONDA, you can give the user a Factory Class that will give him a copy. We'll call our factory class Dealership. Inside dealership, you can have a static function :
    public static Car makeCar(String type)
    if(type.equals("FORD")
    return new FORD();
    else if(type.equals("GM")
    return new GM();
    else if(type.equals("HONDA")
    return new HONDA();
    So when the user needs a car, they will just call
    Dealership.makeCar("FORD").
    This is a good way to hide the implementation of your classes from the user, or if you require complex initialization of your objects.
    Another good example of this is in the Swing library. To get a border around a component, you call static methods on BorderFactory.
    Hope this helped.
    Ed

  • Could someone explain what is Object?

    Could someone explain what is Object? I have a little
    idea what is it, but not sure. Please give me some
    concret example. Thanks.

    An object is an Instance of a class. A class describes a uniwue entity with behaviors and attributes. For example you can consider your arm.
    public class Arm {
      /** How many hairs on the arm. */
      private int hairCount;  // <== This is an attribute
      /** This is a method to set the hairCount Variable.
       * We dont let the outside user set it directly because that would
       * create problems if we wanted to change its implementation to
       * use a float. In addition we might have logic in this setter to
       * prevent bad data.
      public void setHairCount(final int hairCount) {
        // this is a good example of logic in the set method that we dont
        // want the user to bypass.
        if (hairCount < 0) {
          throw new IllegalArgumentException();
        this.hairCount = hairCount; // <-- Note how we have to use this. to
                                    //     access the instance variable
                                    //     insead of the parameter.
      /** This is a method to move the arm.
       * This is behavior of the class. ONLY behavior pertaining to an arm
       * belongs in the arm class. For example, the method "sneeze" would
       * not belong here but be in the Nose class instead. You can see then
       * that each class describes an entity.
      public void move() {
        // code to move the arm.
    }We have only ONE class per type but we can have many objects. For example the description of an arm does not change no matter who'se arm it is. The data in the class changes but not the actual essence of the arm. So we instantiate two arms for every person (assuming they arent disabled). To instantiate is to create a new object like so.
    Arm myarm = new Arm(): This creates a new object that we can work with.
    So consider the old inteview question of, "What is the difference between a class and an object?" The answer is, "A class is a map or desription of an object; whereas an object is a descrite instance of a class."

  • Could someone explain to me why Flash virtual tours don't work after update to Flash Player 10.1?

    Hello there,
    Could someone explain to me why Flash virtual tours don't work after update to Flash Player 10.1?
    Thanks!

    www.privium.nl
    klick the icon image 'virtual tour' upper right corner.
    This works on my other pc, on which I did not update to 10.1 ...
    (I produced this virtual tour; it is stored on the FTP server of the service provider I use for this)
    Awaiting your reply,
    Regards,

  • Could someone explain why mds is using so much CPU?

    Could someone explain what mds is doing if my Mac has been indexed (don't see activity in Spotlight menu bar icon) & I haven't recently added a lot of files?
    I noticed my Mac was slowing down for a while so I looked in Activity Monitor & it says mds is running at 60% CPU. Isn't this something to do with Spotlight indexing?

    If you recently upgraded the OS or installed an application that includes a metadata parser for spotlight (such software generally comes in the form of a package instead of a single icon), it will force spotlight to reindex. Also, restoring from a backup does the same thing.
    Also, if you used mdutil to disable spotlight indexing on the volume and then reenable it, it will force a reindexing.

  • Could someone explain what is wrong with this refind expression?

    Hi, could someone explain what is wrong with this refind expression
    faultCode:Server.Processing faultString:'Unable to invoke CFC - Malformed regular expression "^[0-2][0-9][/][0-1][0-2][/][1-2][0-9]{3}+$".'
    thanks

    ^[0-2][0-9][/][0-1][0-2][/][1-2][0-9]{3}$ works,
    thanks
    dates 12/12/2007matching

  • Could someone explain me about tools like "RICEF"

    Hi Guys,
    Could someone explain me about tools like "RICEF"(I dont know if iam spelling it correctly) and ASAP methodology. Iam wondering how this are related to SAP upgrade and fresh SAP implementation.
    Many thanks in advance.
    Warm Regards,
    Garrick.

    Hi
    It would be helpful to go through the help document of ASAP Methodology.
    The following information may clarify some doubts/requirements you have.
    Generating the Project IMG through ASAP:
    After you have set the project scope, the next step is to generate the Project IMG. From the Business Process Master List (BPML), you can directly access the IMG activities relevant for configuring each process.
    BPML: The Business Process Master List, along with the Business Blueprint, is a key result of the second phase of the Roadmap. Microsoft Excel tables contain the SAP scenarios, process groups, and processes that have been set in scope in the SAP Reference Structure, and are crucial for configuring your SAP System. In Realization, the third phase of the Roadmap, the BPML provides the basis for monitoring and steering test activities and for configuring your SAP System. It contains the titles of the structure items, and displays the status, the owner, links to documentation and links to the SAP System. Amongst other things, the BPML allows you to:
    1) Set your baseline and final scope. These are used for baseline and final configuration.
    2) Access the Project IMG and specific IMG activities assigned to structure items.
    3) Access integration test plans, which help you carry out all required integration tests.
    The Prerequisite is you have set the project scope.
    Process Flow to use the Business Blueprint as a basis for configuring your SAP System:
    1) Set the project scope.
    2) Generate the Project IMG.
    3) Generate the BPML.
    4) From a specific processes in the BPML, you can go to the relevant IMG activities and make Customizing settings.
    Hope this information provides information
    Check the following link for downloading the complete reference document on ASAP.
    http://help.sap.com/printdocu/core/print46b/en/data/en/pdf/SVASAP.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/SVASAQADBCBI/QADBCBI.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/SVASACCT/SVASACCT.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/SVASAPROZ/SVASAPROZ.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/SVASQADBS/Q&ADBSTRUCSTAN.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/SVASAPE/SVASAPE_01.pdf
    Regards

  • I know this isn't really the right place to ask, but could someone explain why when I open Portal 2, that I got off steam and spent a whole day downloading, keeps crashing when I click the Campaign/Single Player mode. It Freezes and then crashes. Help!

    I know this isn't really the right place to ask, but could someone explain why when I open Portal 2, that I got off steam and spent a whole day downloading, keeps crashing when I click the Campaign/Single Player mode. It Freezes and then crashes. Help!

    I know this isn't really the right place to ask...
    Uhm, why don't you go to the right place, then? There are several Steam/Portal forums out there...

  • ParseInt and radix: could someone explain to me what they are ?

    Hi ,
    could someone explain to me in simple words, and maybe with an example, what is the radix, and what "16" means ?
    String fields[] = line.split( "\\s+" );
       // Field 2 : POS
       // Field 3 : Number of words in the Synset (in hex)
        // Field 4 : First word in the Synset
    int words = Integer.parseInt( fields[3], 16 );Thank you !
    Grazia

    Short answer: Radix is the base, 16 means treat the string as a base 16 (hex) number.
    Long answer: Read the documentation (see link provided by jverd). It is very good to understand. Also, look at the following link:
    http://wwwacs.gantep.edu.tr/foldoc/foldoc.cgi?radix� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Could someone explain how to use of the object Thermometer?

    Hi to all,
    please, could someone write a real example explaining how to use the thermometer in order to indicate the progress of a process like to submit a document?
    I need to do it exactly to indicate this process in Adobe Reader.
    Thanks.
    Dan

    Sorry but I surely have explained my problem badly. I understand how to use the object thermometer perfectly.
    I need to use this object in order to determine the progress of the document's transference when I submit a PDF form from Adobe Reader.
    I'm having problems when I try to do this, and I would like to know if there exists some way to do it.
    b I have tried the following:
    var t = app.thermometer;
    t.duration = 1000;
    // How can I know this value?
    t.begin();
    t.text = "Please wait";
    // Is this a madness?
    while( event.target.submitForm( { cURL: [...], cSubmitAs: [...] } ) )
       t.value++;
    t.end();
    Thank you for your time
    Dan

  • Could someone explain the select comparison

    I am supposed to compare inputs on 2 numeric controls and if they are equal they will turn on an LED. I figured out how to do it with the = sign but I am supposed to use the select comparison. Could someone please help me?
    Solved!
    Go to Solution.

    No, you would not have to have another front panel Boolean to use the Select function. You could directly wire the results of anything that returns a True/False. You can also use block diagram constants.
    Message Edited by Dennis Knutson on 01-20-2010 09:47 PM

  • Could someone explain cell coloring

    Hi all,
    I have a Jtable and I want to change the background color of some cells. I know this is well covered here as I have been searching through past posts for the last 2 hours.
    every post says the same to change the background color I will need a cellrenderer. the problem is i dont understand what all this means. i tried the tutorial it went over my head.
    could someone please take me through the steps. I can post my code if needed.
    all help appreciated.

    Visit my website http://www.mekongtech.com check out java page.
    There is sample code that specifically fits your needs.
    Need more hints in details? Email me, I can help.
    Good luck.

  • Could someone enlighten me on this please blutooth on location symbol stays on

    hi all I think this could be a easy fix for more of you knowledgable people , Could someone tell me why the location symbol comes on when I turn my blutooth on , I'm sure it never stayed on before the iOS 8 update ?? Or I could be wrong ! All help welcome thank you

    Thanks Jamrs currently looking at that link on a different note pal could you help me with this please
    HI people could someone tell me after the iOS 8 update when I go to reply to a email iCloud sign in pops up ?? And can this be removed or turned of ?? Any help much welcome Thank you
    iPhone 5, iOS 8

Maybe you are looking for

  • OfficeJet Pro 8500A910 - How to set dpi to print pictures

    How do you set the dpi to print pictures?  The max that shows up on the quality drop down is 600 x 600. Thanks

  • To fix a wonky horizon... New tool?

    Hey guys, Photoshop as it stands is an excellent tool for design, retouching etc, but may I suggest a new tool that could help us people who love to create panoramas? A wonky horizon tool is what we need! Not all horizons from panoramas end up straig

  • Apple TV wireless connection

    Hallo, I have a Apple TV connected to my wireless network created by a TC 500 GB. Till now I have used for the TC the wireless setting "Only 802.11n (5GHz) and everything was working pretty good. Now, since I have bought an iPod Touch, I needed to sw

  • Photo resolution/size for Calendar images?

    I have a small photo (4" x 3.293" @ 150 ppi) that I'd like to use in my calendar. When I drag it onto the calendar page, it seems that it's being enlarged and then I get the dreaded yellow exclamation point thingy telling me it may not print out well

  • Downloading and installing Oracle iLearning

    Hi. I need a help with downloading and installing Oracle iLearning. I have download Oracle iLearning 5.0, and I have Oracle Database 10.2.0.1 and Oracle Application Server 10.1.2.0.2. I have installed all of this products. But iLearning does't work.