How does interfaces overcome the problem of single inheritance?

1) How does interfaces overcome the problem of single inheritance? Can anyone give an example of how it works?
2) In a Java book, I read: "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
Why does different classes require to implement a Java class library?
Can anyone please enlighten? Thanks.

>
2) In a Java book, I read: "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
Hi, let me try to explain this.
Say you have a left hand drive BMW and a right hand drive AUDI. typeOfDrive is a property for these two cars. If i am trying to make this property abstract, i will prefer to put this property in an Interface called Car. My classes BmwCar and AudiCar implement the Car Interface; by which they can use the property typeOfDrive.
So, the behaviour 'typeOfDrive'; when expected to be implemented by Disparate entities BmwCar and AudiCar, we try to abstract that property to a common Interface called Car.
interface Car {
String typeOfDrive;
String getTypeOfDrive();
class BmwCar implements Car {
String getTypeOfDrive() {
   return typeOfDrive;
void setTypeOfDrive(String tod) {
this.typeOfDrive = tod;
class AudiCar implements Car {
String getTypeOfDrive() {
   return typeOfDrive;
void setTypeOfDrive(String tod) {
this.typeOfDrive = tod;
}Now, when you create instance of your disparate classes, you will define the declared property 'typeOfDrive', as 'Left Hand Drive' for BmwCar and 'Right Hand Drive' for AudiCar.
So, "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
You can refer to many web wikis for better examples and explanations.
Regards,
~N~

Similar Messages

  • How does one overcome the problem of songs being in a random order...?

    Happened me earlier today when i was playing around with my ipod classic. I had it in good order in the playlist...but when I went to copy it to the playlist in the ipod classic..it randomised the order. I had to rename the file names so i could see the proper order..but then it wouldnt let me copy them across at all for some reason, so finally i had to covert to AAC and then match up the track times to the playlist in winamp which actually was in order.
    Anyone know a way around this? I searched on the forum and the posts are regarding playlists order and what not...it is quite annoying because i spent like 40 minutes trying to organise one album when it should just be bam click and drag, done.

    >
    2) In a Java book, I read: "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
    Hi, let me try to explain this.
    Say you have a left hand drive BMW and a right hand drive AUDI. typeOfDrive is a property for these two cars. If i am trying to make this property abstract, i will prefer to put this property in an Interface called Car. My classes BmwCar and AudiCar implement the Car Interface; by which they can use the property typeOfDrive.
    So, the behaviour 'typeOfDrive'; when expected to be implemented by Disparate entities BmwCar and AudiCar, we try to abstract that property to a common Interface called Car.
    interface Car {
    String typeOfDrive;
    String getTypeOfDrive();
    class BmwCar implements Car {
    String getTypeOfDrive() {
       return typeOfDrive;
    void setTypeOfDrive(String tod) {
    this.typeOfDrive = tod;
    class AudiCar implements Car {
    String getTypeOfDrive() {
       return typeOfDrive;
    void setTypeOfDrive(String tod) {
    this.typeOfDrive = tod;
    }Now, when you create instance of your disparate classes, you will define the declared property 'typeOfDrive', as 'Left Hand Drive' for BmwCar and 'Right Hand Drive' for AudiCar.
    So, "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
    You can refer to many web wikis for better examples and explanations.
    Regards,
    ~N~

  • Despite ticking the box "remove all website data", when I reset Safari not  all stored cookies are eliminated. How can I overcome the problem? Or is it a bug?

    Despite ticking the box "remove all website data", when I reset Safari not  all stored cookies are eliminated. How can I overcome the problem? Or is it a bug?

    I have done a little experimenting: 1-close all open windows (I found that I had to do this step in order to keep Safari from hanging-will be explained later). 2: Remove all data in Prefs. 3: Immediately close the prefs window (no window should be open at this point) and quit Safari. Try to complete step 3 fast as possible; I have it down to a few seconds. The reason I urge you to close all windows is that Safari hangs until forced to quit upon immediately quitting after removing cookies. I think the auto page reload in Lion is the cause of these hiccups but I can't be sure about that. The hasty quit I found is crucial to success. Don't know why that is but it could prevent the data from re-populating. A quick flush, if you will.  Hit me back if you need any of my suggestions clarified; a bit wordy, I know

  • How do I know if I have a wifi problem with my new iPad 3 (it seems very slow) and how does one address the problem with apple if there is one?

    I just read about the possible issue that some folks are having with their new iPad wifi (my seemed to be running very slowly but I thought that perhaps it was just me overreacting).  How do I know if I have a definite problem, and what is my recourse?  Do I need to take it to an Apple store for testing?  I have apple care which I assume addresses stuff like this.  Thoughts?  Thx so much.

    Your iPad is covered by the normal warranty for one year. If you have AppleCare that extends the coverage. If you feel there is a problem with your wifi reception visit an Apple store with your iPad for a consultation. Be sure to make an appointment before you go.

  • Drop down windows are blank. How does one correct the problem?

    I  am having trouble with dropdown windows in Photoshop; they are blank.  What is the cause and how can i fix it?  i am using a Wacom Tablet

    Do you mean the menus?
    And which OS version are you using?

  • My accelerometer outputs a charge proportional to the acceleration to which the accelerometer is subjected to.Can the labview output the waveform in voltage?if not how can i overcome the problem ?

    Im am using a labview RT with PCI-7030 DAQ board and a CB-68LP .This is urgent.can somebody please help?

    I suggest you consult the manifactuer of the devices to see if they sell or can recomend signal conditioning gear to output a voltage or a current.
    Generally speaking, the charge can be measured by using a capacitor (where V=Q/C) but the leakage current that is introduced when monitoring the voltage across the cap will adversly affect the measurements.
    I have designed circuits to do this but it quite un-orthodox.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • When downloading CS6 Beta how do you overcome the problem of being told to close Bridge.exe when its

    Whilst trying to download CS6 Beta I'm told to close Bridge.exe, but its already closed?  Any ideas about what to do next/

    Hi Chris,
    I did esolve the issue by clicking bottom right task Bar and then right clicking on the bridge icon to operate Br QE

  • I'm having problems upgrading from 10.6.8 to Yosemite.  My computer locks up after the download and installation process.  Does anyone know how I can overcome this problem?

    I'm having problems upgrading from 10.6.8 to Yosemite. My computer locks up after the download and installation process. Does anyone know how I can overcome this problem?

    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.

  • HT1386 Sry for disturbing, but i would to ask that how to overcome the problem of synchronising ? Itune showing me that the sync session is failed to start with my Ipad mini. Any ideas about what is going on ?

    Sry for disturbing, but i would to ask that how to overcome the problem of synchronising ? Itune showing me that the sync session is failed to start with my Ipad mini. Any ideas about what is going on ?

    What are you trying to sync?
    I see you are on ios 7.
    I also had upgraded my iPad Mini to ios 7 & then the 1st time I tried to open a Numbers file that was set up to sync w my MacBookPro, I got a warning that I would not be able to sync it any more w my Mac until I upgraded to Mavericks.
    So if you are trying to sync Numbers, Pages or Keynote files between your iPad mini in ios 7 and a Mac that hasn't been upgraded to Mavericks that could be the problem.
    I was very shocked to get that message since I bought Numbers on the iPad so that I could have a particular file on both devices & keep them synced. I had no clue when I upgraded to ios 7 on the iPad Mini that it would make it so the files in the iWorks apps woudln't sync any more.
    So I finally decided to go ahead & upgrade to Mavericks after carefully preparing & updating other software so that it would work w Mavericks. But I got error messages so haven't even been able to download Mavericks & now having 2nd thoughts about doing so.
    iPad mini ios 7
    MacBookPro Mid 2012 Mountain Lion
    iphone 4S ios 6

  • HT5132 I can't click on the 'Learn More' or 'Ok' options so cannot use Aperture. How do I overcome this problem? I use OS X Lion 10.7.4

    I can't click on the 'Learn More' or 'Ok' options so cannot use Aperture. How do I overcome this problem?
    I use OS X Lion 10.7.4.
    I also don't seem to be able to disable the Mobileme account via the system preferences option as mobileme doesn't allow access with my password.

    Have you tried to disconnect from the Internet before launching Aperture? Then the MobileMe webpage should not be shown and you should be able to access the Aperture preferences and remove the MobileMe account from the "Preferences > Web" panel.
    If this does not succeed, (Force) quit Aperture, log off and log on again, then remove the Aperture Preferences file (~/Library/Preferences/com.apple.Aperture.plist)
    from the Preferences Folder in your User Library and try again to launch Aperture. See http://support.apple.com/kb/HT3805 on how to remove the Preferences.
    Regards
    Léonie

  • HT4995 My iPad 2 Location Service works fine but does not work on my home Airport router. How can I fix the problem?

    My iPad 2 Location Service works fine but does not work on my home Airport router. How can I fix the problem?

    lbryan1987 wrote:
    I dont want the button problem solved i need to know how to restore the phone without using that button or going into settings
    You don't in the condition it's in. You will either have to get the phone replaced by Apple or pay a 3rd party to repair it.
    there seriously should be more than two ways to solve this other wise apple is useless and we will never buy another apple product.
    Seriously? It's physically broken!

  • I Ipod class wont play TED and other video podcasts.  The genious bar could not figure out the problem.  This problem is not isolated to a single computer.  Secondly, the convert to ipod version feature in Itunes does not resolve the problem.

    My Ipod classic wont play TED, The Grid, Techzilla and other video podcasts (but not all video podcasts).  The genious bar could not figure out the problem. Instead, the Apple store gave me credit towards a new classic, which produced the same problem.  This problem is not isolated to a single computer.  Secondly, the convert to ipod version feature in Itunes does not resolve the problem.  Lastly, I tried restoring the ipod to no avail.  I've heard this is a video codec problem. 

    See this extensive older thread on the issue.
    https://discussions.apple.com/thread/2813428?start=45&tstart=0
    B-rock

  • Why does not the scroll on tbody in new versions of Firefox and how it can solve the problem?

    why does not the scroll on tbody in new versions of Firefox and how it can solve the problem?

    scrolling overflow on tbody is no longer supported because that is not allowed in CSS 2.1 specification.
    See [https://developer.mozilla.org/en/CSS/overflow notes for overflow]

  • I find I am unable to print any photo because the program "Can't find a theme and the Print command wont work without at least one theme. How can I overcome this problem?

    I find I am unable to print any photo because the program "Can't find a theme and the Print command wont work without at least one theme. How can I overcome this problem?

    reinstall iPhoto
    see this discussion down a few from your post
    https://discussions.apple.com/thread/5426566?tstart=0
    LN

  • Fire FTP does not work with Firesfox 4. It worked OK with version 3. How can I get a New Fire FTP? Last version of FTP does not solve the problem

    Fire FTP does not work with Firesfox 4. It worked OK with version 3. How can I get a New Fire FTP? Last version of FTP does not solve the problem

    I need to know if it's 64-bit or 32-bit.
    If it's 64-bit, try copying the mms.cfg file from C:\WINDOWS\syswow64\Macromed\Flash to C:\WINDOWS\system32\Macromed\Flash

Maybe you are looking for

  • Loading external htm file to display in TextArea

    Hi, I'm trying to think how I can load an external HTML file ad display the page in a TextArea and assign an external css file to style the text. Would appreciate any advice and sample code. Alex

  • Query on multiple sources

    Hi! I can't get OBI EE to work on this issue: I have an Oracle table (dimensiontable) with a certain primary key and I also have an Excel sheet with a defined name on a table source which contains a column that logically references the dimension's pr

  • After upgrading I have two versions of Lightroom

    I've just installed the 5.2 upgrade. Can I now just delete my previous 4.4  version of Lightroom?

  • Pdf converter  thai language

    I need a pdf converter that uses thai language

  • Creative Cloud Hong Kong release date ?

    When can creative cloud be expected for Hong Kong / Asia release ? Our trial runs out soon, yet it is not available for our HK business ? Suggestions ? After testing and happy to subscribe for 1 year in Australia, we weren't impressed to learn the co