Why Interface is necessary in Java?

Hi,
we know interface is like a skeleton, that contains only method signatures and variables. Methods must be public, abstract and variables must be public static final.
simply we are implementing interface and defining all the methods in our class. we can do this without going to interface.
why we have this interface? please explain me with simple real time example.
Thanks and Regards,
Periyasamy

simply we are implementing interface and defining all
the methods in our class. we can do this without
going to interface.Huh?
why we have this interface? please explain me with
simple real time example.Do you mean "real-life"?
Example
There is no specified implementation type of the return value, and neither should there be one, so it can be easily replaced.

Similar Messages

  • Why it is necessary that public class name should  same as filename in java

    hi,
    why it is necessary that public class name should same as filename in java.
    As I know that it is a convention, but I want the information why this convention is made.
    thanx.

    user13445117 wrote:
    but suppose if i am creating a java file with default access modifire then we do not need to save the file name as a class name.So, your question is "Why does the rule about top-level classes being in a file of the same name apply +only+ to public classes"?
    If it were applied to all classes, then we could never have two top-level classes in the same file. Doing that is generally not a good idea, but it might be useful from time to time. EJP already told you why it applies to public classes, and, since these are the most common by far, it's a fair compromise that it apply to them but not to other classes.
    Was this the reason the original designers did it that way 15 or so years ago? Don't know, don't care, but it's one plausible explanation. Maybe it was just a balance between simplicity and clarity on the one hand, and flexibility on the other.
    It's certainly not something I can see caring that much about, unless you're doing an in-depth history on Java, or writing an in-depth treatise on computer language and compiler theory.

  • Discussion: Why no centralize development for Java (like the one in ABAP)

    I am reading the NetWeaver Development Infrastructure, and noticed that due to the distributed development nature of Java, SAP recommend The Four-System Landscape for the development lifecycle.
    Each developers has their own local development environment, that's why it is necessary to 'reconcile' the environment using one more layer of system. Although they checked out the particular Development Object, the necessary library from the central is being copied by DTR to the local environment. However, there are still possibilities that someone changes the library, or other classes that being refered. And we are not talking only about the business logic, but other object in the persistance level too. Let's say your program refered to a certain field in a certain table, but someone else had changed the field name. Or even worse, you want to get the setting value from a certain setting table, but someone else had deleted the value of that record (for whatever reason).
    In short, I believe there are many 'reconcilliation' process that need to be done when the development environment is not centralized. These problems won't happen in the ABAP world, because you will notice the problem straight away when you activate your component, or test run it. In distributed environment, you will only notice it when you check-in your development object back, but it might be after some time lags, and you might not remember which part need to be taken care of.
    Not only this, the setting of 'correct' IDE environment in each local PC must be done properly. Again, in ABAP you just need to install SAP GUI and it will be your development environment.
    So, I had discussion with a friend of mine, and he asked, why there is no central development environment, like the one in ABAP? Hmm, to be frank, I also don't know. Performance problem? I notice that most IDE in the market based on the assumption that development will be done locally. Or is it for the convenient purpose, so that people can keep the development eventhough there is no connection to central server? But what is the cost for this convenient?
    What other people think?
    rgs,
    Hiroshi
    ps: As you might notice, this thread is not marked as question. I am just curious of what other people think about this issue. There will be no points rewarded for the replies.

    Hello Satya,
    So if it's a 'mere' technical limitation, then there should be a way to create centralized development for Java
    It might be an old mainframe environment, but from the development process point of view, centralized environment offers benefit where lots of versioning problem (library or data dictionary) can be solved.
    I used to work in a distributed development environment to create a web based FI/SD/MM related application. We have tons of classic problem of '<i>it is working in my environment, but not in yours</i>' type of thing. With centralized (read: ABAP), version integrity problem can be reduced to minimum.
    For the NWDI itself, I think SAP now moves toward embracing the open source platform to support the development environment. From what I've understood, Ant, for example will be used as the build tool. My personal opinion is, better if SAP creates it's 'proprietary' environment to centralized the java development process. Then it will save lot's of hidden cost during the implementation of new application/enhancement/maintenance in the whole supply chain.
    rgs,
    hiroshi

  • Is an audio interface still necessary?

    I am using
    Logic Pro X, Samson L2400 24 channel mixer connected via USB, is an audio interface still necessary to record all 24 tracks separately?
    Noob hardly expresses my incompetence here so thank you for your patience.

    MacDyver wrote:
    I am very appreciative for the assistance however it confuses me slightly more in that I do have a Roland Octa-Capture however it also connects via USB. I guess it is also useless
    Articles I read state USB can theoretically carry 255 channels but everything else points to L/R Stereo.
    It appears a fire sale is in order and purchase of a firewire mixer or interface may be my only option
    Thanks everyone hope I can find a solution
    I don't quite get your conclusion: the fact that an interface connects via USB, does not make it useless. And according to a quick look at specs the octacapture aka UA1010 has 10 inputs; you could aggregate that with the Samson and another interface with at least 12 inputs, and there you have your 24 inputs: 10 from the UA1010, 2 from the Samson itself, and 12 from whatever extra interface you'd use.
    Getting one interface with 24 or more inputs may be a more secure and simpler route to take though.
    I also don't get why you almost blame our appreciated assistance - by "howevering" it - for confusing you about your 10-input audio interface, when you never even mentioned you had it in the first place?

  • Why interfaces can not declare static methods?

    Why interfaces can not declare static methods?

    Why are you shouting?
    Is your internet broken?
    [http://www.google.co.uk/search?q=interface+static+methods+java] 2,440,000 hits.

  • Why can't i install java on os 10.7, under install it says error  something about java script

    why can't i install java on os 10.7, under install it says error  something about java script

    If you can't get any software updates, there is something wrong and I would suggest reinstalling Lion.
    What errors do you get when you try to install the updates?
    What is the build number of Lion. Look in About this Mac and click on the version number.

  • Is an audio interface really necessary?

    Ok, right now I have my condenser mic hooked up to a phantom power and from the phantom power to the computer. All my recordings come out clear and loud. But my friend told me that if I get an audio interface, my recordings will sound much better. Well is it true? What are the benefits of an audio interface?
    thanks

    I actually use a variety of interfaces. Yesterday I spent the day with one from M-Audio and, while not as good sounding as the RME in my sig, the results were surprisingly good.
    While there are a number of technical reasons why interfaces will sound better than going into the computer directly, aside from the technical mumbo jumbo, I do find a big jump in sound quality using an interface vs. a direct input, and not simply the difference between one flavor preamp and another.
    Obviously, there are interfaces, and then there are interfaces! But even so, I've yet to use any interface that hasn't worked noticeably better than plugging directly into the computer.
    That said, if someone is just starting out and wants to plug and play, and is more than happy with the quality of the computer's inputs, then they're wasting their money buying anything else. No one should buy anything they don't want or need!
    But if someone is striving for better sound quality than what comes with the computer, the fact that interfaces add obvious flexibility shouldn't shroud the fact that they also improve sound quality under the hood.
    kbeartx does make an excellent point, one of two that frequently degrade conversations about gear. Of course experience is all important! And the other: "it's all about the music," as if discussing equipment suggests otherwise. Still, equipment, and discussing it, has a value. Equipment and experience are not mutually exclusive.
    It's like surgeons speaking about scalpels. An experienced surgeon will do a better job with a steak knife than an inexperienced surgeon will do with a finely-honed scalpel. Still, no one would denigrate any surgeon for seeking the best tool available.
    That's all this is.
    Inifinity239 has a steak knife and is wondering if a scalpel works better. As someone who has used both (to continue this now very tortured metaphor )... I would say of course!

  • Why we need reference in java?

    Hi
    I faced one problem while I was doing heapdump analysis.I had to find memory leak suspect.
    Somewhere in parent node I have found soft reference.
    My question is that why we need reference in java?
    and why IBM jdk1.4.2 and above have inbulit class like
    softreference
    weakreference
    phatomreference

    These Reference objects have special ways of interacting with the garbage collecor. A normal reference is, in comparison, called a "hard" reference. If an object is only reachable through a special reference it is said to be "softly reachable" or the like, and the garbage collector can collect it. When this happens the reference object is cleared, and will return null if you try to acccess the object through it.
    SoftReference tells the garbage collector "On the whole I'd like you to hang on to this, but feal free to delete it if you're short of space."
    Weakly and Phantom reachable objects are collected as normal.
    A typical use of a WeakReference is when you want to hold onto a pointer to an object as long as that object exists, but allow it to be collected when there are no other references. For example, some object might listen for events on some window, but if you abandon the object you don't want the listener to prevent the object being disposed of.
    A typical use of a SoftReference is when you've arrived at some sizable data object through a moderately expensive process e.g. retrieving it from a database. You can rebuild it if it's lost, but you can save time if it's still there when you want it again.
    A PhantomReference is used instead of finalize(). You can arrange for references to be added to a queue when cleared, and you can have a background thread removing references from the queue and doing what you like with them. By extending the Reference type you can store information needed for a clean-up.

  • Plugin-container.exe : what is it, why is it necessary, can I delete it

    Continued from the "plugin-container.exe : what is it, why is it necessary, can I delete it" thread:
    1) When people say Firefox uses up a lot of CPU/Memory, they are telling the truth. Tools like Task Manager and Process Explorer show you how much CPU/Memory Firefox is using up. Stop calling people liars when they say Firefox is using up X Memory. Stop making baseless accusations like "you're running other programmes that are causing your CPU to skyrocket and Firefox to freeze". Task Manager and Process Explorer don't lie. Take yourself off the thread because you're not helping anyone, you're creating anger and hatred, you're basically trolling. If you have no valid advice to offer, keep your mouth shut and stay away instead of launching into the "you're a liar" nonsense.
    2) Stop typing in caps
    3) Refrain from using profanity and ad hominem attacks
    4) If you claim you're abandoning Firefox for another browser, fine: now get off the board and go away instead of posting inflammatory hatred against Mozilla since you're no longer using Mozilla
    5) Stop attacking and/or ignoring the advice of Mozilla representatives like Morbus
    6) Morbus: the Firefox Safe-Mode advice you frequently dispense is the most rejected advice because most people do not want to mess with their browsers, especially people who are not not knowledgeable about safe-mode, add-ons, disabling, etc. I fully agree that people must learn how to diagnose the problems on their own and find solutions on their own, but not all people are capable of learning how to do that. Computers are easy for many people, but not all people. The Safe-Mode solution appeals to a '''minority '''of people who are comfortable with picking apart their browser and picking apart other things to find solutions, not the majority, who fear making things worse.
    == This happened ==
    Every time Firefox opened
    == Today 6/22/2010

    7) Stop telling people to remove add-ons and plug-ins and scripts. Firefox was made specifically to enable to build their own browsers. Firefox was made for the purpose of allowing people use all the add-ons and plug-ins and scripts they wanted. No other browser offers that range of add-on/plug-in/script support. Removing the add-ons and plug-ins and scripts eliminates the purpose of Firefox. If Mozilla representatives want to insist that removing add-ons and plug-ins and scripts are the solution, then Mozilla is telling us that its browser is no different from IE or Chrome, in which case Mozilla has given us a reason to stop using Mozilla.

  • I recently purchased tunes with iTunes gift card.  I still have $ left on my card and now I'm asked to verify my account. Why is this necessary?

    I recently purchased tunes with iTunes gift card.  I still have $ left on my card and now I'm asked to verify my account. Why is this necessary?

    Because iTunes simply wants you to verify your name &amp; address is correct in your account info.

  • Creating an Account on Azure... Why is it necessary to give any credit card information? Do they charge something?

    Hi,
    I am new to cloud and find azure good to work with clouds. But I was trying to create trial an account there and it is asking for credit card. Please tell me if this is trial then why it is necessary to give the card details? Moreover, being a trial version,
    many of us don't have any cards these days. So till that time we have to wait for the card? Please provide some facility to learn and give some period of trial without any card details.
    Thanking you.
    Regards,
    Syed

    Hi,
    Please have a look at Azure free trial FAQ:
    http://azure.microsoft.com/en-gb/pricing/free-trial-faq/, We use the phone number and credit card for identity verification. We want to make sure that real people are using Azure. We
    do not bill anything on the credit card. So, please wait for the card. If you are a student and don't have a card, please try this link:
    http://www.WindowsAzurePass.com/azureu, refer to
    http://blogs.msdn.com/b/mast/archive/2013/10/12/windows-azure-30-day-s-free-trial-uncovered.aspx for more details.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Why can't we view Java on the iphone?

    Why can't we view java. I understand that Steve Jobs said in 2010 that it was a dying technology however lots and lots of sites still use it and I am tired of needing my laptop every time I want to use one of those sites. This includes large companies such as BBC, Lottery etc. can I download another browser and it will work, eg if I don't use Safari?

    Why can't we view java.
    Because the iPhone does not have support for Java.
    lots and lots of sites still use it
    Really? I haven't come across one in years. I don't even have it installed on my computers.
    This includes large companies such as BBC, Lottery etc.
    I use both of those sites, and have never come across the need for Java. Are you sure you are talking about Java?
    Provide some links to pages you are unable to view.
    can I download another browser and it will work, eg if I don't use Safari?
    You can download another browser if you want. You'll have to read the AppStore descriptions for browsers that claim to support Java and then try them out.

  • Why do i keep having java script application error "on HidePage called" everytime i launch, browse and close Firefox?

    why do i keep having java script application error (on HidePage called) everytime i launch, browse and close Firefox?
    == URL of affected sites ==
    http://
    == User Agent ==
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4

    Hello Bo.
    It's possible that you are having a problem with some Firefox add-on that is hindering your Firefox's normal behavior. Have you tried disabling all add-ons (just to check), to see if Firefox goes back to normal?
    Whenever you have a problem with Firefox, whatever it is, you should make sure it's not caused by one (or more than one) of your installed add-ons, be it an extension, a theme or a plugin. To do that easily and cleanly, run Firefox in [http://support.mozilla.com/en-US/kb/Safe+Mode safe mode] (don't forget to select ''Disable all add-ons'' when you start safe mode). If the problem disappears, you know it's from an add-on. Disable them all in normal mode, and enable them one at a time until you find the source of the problem. See [http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes this article] for information about troubleshooting extensions and theme and [https://support.mozilla.com/en-US/kb/Troubleshooting+plugins this one] for plugins.
    If you need support for one of your add-ons, you'll have to contact its author.

  • Interfacing with vb from java

    Hi,
    is it possible to interface with vb from java.
    I have a vb program with a method stop() which just stops the program. I want to be able to call this method from my java program in order to stop the vb program.
    Is this possible?
    I d really appreciate any help.
    Thanks Jim

    Hi,
    there is a Java / COM bridge. You can reach COM from Java and
    VB from COM.
    Have fun,
    Klaus

  • Why is it necessary to make the block synchronized while iteratiing

    Why is it necessary to make the block synchronized while iteratiing thru Synchronization Wrappers?
    here is the code sample for same:
    Collection c = Collections.synchronizedCollection(myCollection);
    synchronized(c) {
    Iterator i = c.iterator(); // Must be in synchronized block!
    while (i.hasNext())
    foo(i.next());
    }

    If at the first place I am getting all the methods synchronized by calling
    Collection c = Collections.synchronizedCollection(myCollection);
    that means no two threads can enter the data structure of this collection, I am not getting how ConcurrentModificationException will be thrown while iterating thru this collection?
    Can u please explain in a little depth?

Maybe you are looking for

  • Trying to connect my Iphone to my car radio.

    My connection is in my glove compartment. Can anyone point me in the right direction so I can listen to my music and pandora/iheart radio?

  • Legacy text mode

    Subject changed by moderator Hi Experts, I am working on a program that opens a file writen in English. It works perfectly fine. The syntax is as follow:  OPEN DATASET f1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. I then add some French in the file, I

  • How to Load 120GB of Music with an 80GB Hard Drive

    Hey All, I am a newbie here, and I'm a little confused... How do I load 120 GB of music into my iPod with only an 80 GB hard drive? Thank You !!!

  • How to get Track information in Itunes 12 for windows 8.1

    I just installed Itunes on my Asus. I am running Windows 8.1 . Some of my library which was already loaded in my Windows Media Player was brought into Itunes. It did not have track information because when I ripped it, I was working without an intern

  • J2EE Tutorial With Remote Client

    Where can I find a J2EE tutorial that demonstrates a remote client accessing an EJB? The Sun tutorial are all localized examples. Does a remote client have to run on a J2EE server? Thanks, -Ray