I want to make sure about abstract classes issue

Hello,
I have an interface with two methods.
interface call{
void trial (int p);
void show();
And an abstract class that implements that interface with overriding only one method of the two.
abstract class client implements call {
public void trial(int num) { System.out.println(num);}
In the main method, I wanted to instantiate the implementing class in order to make use of the one method it overrides, but I received an error that the class as abstract, cannot be instantiated.
class test{
public static void main(String args[]) {
//creating object reference to the implementing class
client c = new client(); //the error is here
c.trial(5);
//creating an interface reference
call m = new client(); //also doesn't work
m.trial(5);
So does I understand from this that if a class does not provide full implementation of an interface (i.e. abstract class), it cannot be used inside my program?
Thanks!

Please use code tags (see CODE button above posting box). Also, please use standard Java conventions of using a capital letter to start a class name.
You are getting that error message because you didn't define show, and the interface requires it. You have to extend the Client abstract class to define show.
You can make an anonymous class that defines show:
Call m = new Client() {
   public void show() {
      System.out.println("Do something.");
m.trial(5);Or, you can make a non-anonymous class that defines show:
class MyClient extends Client {
   public void show() {
}In this example, "show" doesn't actually do anything, but it does satisfy the interface. You can put the same "show" as I put in my anonymous class, or you can do whatever you want in "show".
Then, in your "main", you'd have:
MyClient client = new MyClient();
client.trial(5);
//or
Call anotherClient = new MyClient();
anotherClient.trial(6);
//or
Client yetAnotherClient = new MyClient();
yetAnotherClient.trial(7);

Similar Messages

  • I want to upgrade my iphone and want to make sure that all my phone and email contacts along with my photos and music get transfered to new phone.  How do I go about doing that?

    I want to upgrade my iphone and want to make sure that all my phone and email contacts get transfered along with my photos, videos and music to new phone.  How do I go about doing that?

    http://support.apple.com/kb/ht2109

  • Question about abstract classes and instances

    I have just read about abstract classes and have learned that they cannot be instantiated.
    I am doing some exercises and have done a class named "Person" and an abstract class named "Animal".
    I want to create a method in "Person" that makes it possible to set more animals to Person objects.
    So I wrote this method in class Person and compiled it and did not get any errors, but will this work later when I run the main-method?
    public void addAnimal(Animal newAnimal)
         animal.add(newAnimal);
    }Is newAnimal not an instance?

    Roxxor wrote:
    Ok, but why is it necessary with constructors in abstract classes if we don�t use them (because what I have understand, constructors are used to create objects)?Constructors don't create objects. The new operator creates objects. An object's c'tor is invoked after the object has already been created. The c'tors job is to initialize the newly-created object to a valid state. Whenever a child object is created, the parent's c'tor is run before the child's c'tor, so that by the time we're inside the child's c'tor, setting up the child's state, we know that the parent (or rather the "parent part" of the object we're initializing) is in a valid state.
    Constructor rules:
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • I'm moving from a iPhone 4S to an iphone 5s but and I'm changing SIM card with same number but I want to make sure that all my pictures go onto my new phone how can I do that?

    I'm moving from a iPhone 4S to an iphone 5s but and I'm changing SIM card with same number but I want to make sure that all my pictures go onto my new phone how can I do that?

    Hello Bethanygrace_m7,
    Thank you for contacting Apple Support Communities. You can take a look at this article about transferring content from your old iPhone to a new one:
    Transfer content from an iPhone, iPad, or iPod touch to a new device
    http://support.apple.com/kb/HT2109
    Here is another thread from the Communities about migrating data from an old iPhone to a new one:
    Migrating data from old to new iPhone?: Apple Support Communities
    https://discussions.apple.com/thread/2038778
    Regards,
    Jeff D.

  • What is best antivirus software for Mac Mini? Recently the Trovi virus was on my computer and I want to make sure it is completely gone.

    What is the best antivirus software for Mac Mini?  I had thought Mac's were safer from viruses but recently I think the Trovi virus infected my computer, I have taken steps to remove but want to make sure computer is clean.

    To learn how to defend yourself from the threat of adware read How to install adware.
    There will always be threats to your information security associated with using any Internet - connected communications tool:
    You can mitigate those threats by following commonsense practices
    Delegating that responsibility to software is an ineffective defense
    Assuming that any product will protect you from those threats is a hazardous attitude that is likely to result in neglecting point #1 above.
    OS X already includes everything it needs to protect itself from viruses and malware. Keep it that way with software updates from Apple.
    A much better question is "how should I protect my Mac":
    Never install any product that claims to "clean up", "speed up",  "optimize", "boost" or "accelerate" your Mac; to "wash" it, "tune" it, or to make it "shiny". Those claims are absurd.Such products are very aggressively marketed. They are all scams.
    Never install pirated or "cracked" software, software obtained from dubious websites, or other questionable sources.
    Illegally obtained software is almost certain to contain malware.
    "Questionable sources" include but are not limited to spontaneously appearing web pages or popups, download hosting sites such as C net dot com, Softonic dot com, Soft pedia dot com, Download dot com, Mac Update dot com, or any other site whose revenue is primarily derived from junk product advertisements.
    If you need to install software that isn't available from the Mac App Store, obtain it only from legitimate sources authorized by the software's developer.
    Don’t supply your password in response to a popup window requesting it, unless you know what it is and the reason your credentials are required.
    Don’t open email attachments from email addresses that you do not recognize, or click links contained in an email:
    Most of these are scams that direct you to fraudulent sites that attempt to convince you to disclose personal information.
    Such "phishing" attempts are the 21st century equivalent of a social exploit that has existed since the dawn of civilization. Don’t fall for it.
    Apple will never ask you to reveal personal information in an email. If you receive an unexpected email from Apple saying your account will be closed unless you take immediate action, just ignore it. If your iCloud, iTunes, or App Store account becomes disabled for valid reasons, you will know when you try to buy something or log in to this support site, and are unable to.
    Don’t install browser extensions unless you understand their purpose. Go to the Safari menu > Preferences > Extensions. If you see any extensions that you do not recognize or understand, simply click the Uninstall button and they will be gone.
    Don’t install Java unless you are certain that you need it:
    Java, a non-Apple product, is a potential vector for malware. If you are required to use Java, be mindful of that possibility.
    Java can be disabled in System Preferences.
    Despite its name JavaScript is unrelated to Java. No malware can infect your Mac through JavaScript. It’s OK to leave it enabled.
    Beware spontaneous popups: Safari menu > Preferences > Security > check "Block popup windows".
    Popup windows are useful and required for some websites, but unsolicited popups are commonly used to deceive people into installing unwanted software they would never intentionally install.
    Popups themselves cannot infect your Mac, but many contain resource-hungry code that will slow down Internet browsing.
    If you ever receive a popup window indicating that your Mac is infected with some ick or that you won some prize, it is 100% fraudulent. Ignore it.
    The same goes for a spontaneously appearing dialog insisting that you upgrade your video player right this instant. Such popups are frequently associated with sites that promise to deliver movies or other copyrighted content "for free".
    The more insistent it is that you upgrade or install something, the more likely it is to be a scam. Close the window or tab and forget it.
    Ignore hyperventilating popular media outlets that thrive by promoting fear and discord with entertainment products arrogantly presented as "news". Learn what real threats actually exist and how to arm yourself against them:
    The most serious threat to your data security is phishing. Most of these attempts are pathetic and are easily recognized, but that hasn't stopped prominent public figures from recently succumbing to this age-old scam.
    OS X viruses do not exist, but intentionally malicious or poorly written code, created by either nefarious or inept individuals, is nothing new.
    Never install something without first knowing what it is, what it does, how it works, and how to get rid of it when you don’t want it any more.
    If you elect to use "anti-virus" software, familiarize yourself with its limitations and potential to cause adverse effects, and apply the principle immediately preceding this one.
    Most such utilities will only slow down and destabilize your Mac while they look for viruses that do not exist, conveying no benefit whatsoever - other than to make you "feel good" about security, when you should actually be exercising sound judgment, derived from accurate knowledge, based on verifiable facts.
    Do install updates from Apple as they become available. No one knows more about Macs and how to protect them than the company that builds them.
    Summary: Use common sense and caution when you use your Mac, just like you would in any social context. There is no product, utility, or magic talisman that can protect you from all the evils of mankind.

  • Is this good usage? i just want to make sure

    i just want to make sure if this is good usage or avreage usage?
    i do want to note that i have been using my iphone none stop since i unplugged it.
    these are the apps ive been on
    messages < alot of this
    Kik < alot of this aswell not much
    facebook < some not much
    instagram < some not much
    app store < once the whole day
    pandora < minimal
    camera < once or twice barley
    apps open are only messages and kik the rest i have them closed

    There is no such thing as "good" or "average" usage.
    Does the battery life meet your needs, if it does, dont' worry about it.
    If it doesn't, a search of the forums will reveal dozens if not hundreds of postings about battery life.

  • Just got a new 80gb ipod Just want to make sure its suposed to do this(help

    ok so i was at the movies last night and i turned my ipod off by holding the play button and it turned off like it has before but before it would turn right on
    and when i turned it on today i saw an apple logo
    is it ok
    its my first ipod just want to make sure its fine
    thanks

    After 14 hours of inactivity your iPod goes into hibernation. It's nothing to worry about. Also see this article: http://docs.info.apple.com/article.html?artnum=60945

  • Greeting,  I want to reformat my external hard drive using Mac OS Extended (Journaled, Encrypted ) but before formatting it, I want to make sure that if I loose the hard drive or the hard drive get stolen, no one will be able to retrieve or recover the in

    Greeting,
    I want to reformat my external hard drive using Mac OS Extended (Journaled, Encrypted ) but before formatting it, I want to make sure that if I loose the hard drive or the hard drive get stolen, no one will be able to retrieve or recover the information on it so could you tell me what kind of encryption will be used or is there any way to recover the information?
    Thanks!

    I think FileVault is used to encryp internal hard drive but I wanna encrypt an external hard drive with Mac OS Extended Journaled Encrypted which is completely different!

  • I want to take remote access from an iTunes library off of my iPad ...when I hit edit from the remote app it pulls that library up ..if I delete it I just want to make sure that I'm not remotely wiping out the library, just access to it from my iPad ?

    I want to take remote access from an iTunes library off of my iPad ...when I hit edit from the remote app it pulls that library up ..if I delete it I just want to make sure that I'm not remotely wiping out the library, just access to it from my iPad ?

    Call the apple store you got it from and ask them. Sometimes in the past they've extended the 'no questions asked return' but only Apple can tell you for sure.

  • I bought an iPad and want to make sure it's on the same apple account but my phone always come up with a different apple Id?

    I bought an iPad and want to make sure it's on the same apple account but my phone always come up with a different apple Id?

    Remember - if you bought any apps with another ID you cannot update them with a different ID.
    Try changing the ID in the App Store. Tap on Featured - swipe to the bottom of the screen - tap on the ID in the bottom left corner - and see if you can change it that way.
    If that doesn't work, sign out of your account altogether, restart the iPad and then sign in again.
    I guess I should ask - what ID is it coming up with and why is it coming up with that ID?
    Message was edited by: Demo

  • My old computer (a Sony) with my iTunes crashed. I have a new MAC and want to make sure I can keep all of my music (mostly from old CD's that have been lost). I bought iTunes match hoping that would work but it isn't using the data on my phone. HELP!

    My old computer (a Sony) with my iTunes crashed. I have a new MAC and want to make sure I can keep all of my music (mostly from old CD's that have been lost). I bought iTunes match hoping that would work but it isn't using the data on my phone. HELP!

    Since you have purchased a new Mac (which, BTW, is not typed in all capitals) why not buy a Time Capsule <http://www.apple.com/airport-time-capsule/> which is designed specifically to work with OS X and Time Machine?
    You don't say what part of your Sony "crashed." If it was not the HDD it is possible to take the computer apart, put the HDD in an external case, then recover the data off of it (including the music) simply drag-n-drop. If it was the HDD that "crashed" that makes it more difficult.
    If you are able to recover the music from the Sony you can then add it to the iTunes library on the Mac and iTunes Match will then scan, match and upload the tracks to be mirrored in the cloud.

  • I was buying a book and it wasn't responding and it finally did but when I open the window it had 6 of the same book downloading and I want to make sure that they are not going to charge me for 6 of the same book .

    I bought a book and at fierst the download was not responding.it tookna while to respond and when it did there was 6 books downloading but they were the same book and i want to make sure they don't charge me for all 6 books . What can i do ?

    This forum is for making podcasts: the best place to ask would be in the iTunes Store forum:
    https://discussions.apple.com/community/itunes/itunes_store
    or you could contact iTunes Support;  http://www.apple.com/support/itunes/

  • I need to download all of my photos from my iPhone 4S and my iPad 2 to my MacBook Air. I want to make sure all my photos are not lost and that they do not return to the original devices because of the cloud. Can someone please help ?

    I need to download all of my photos from my iPhone 4S and my iPad 2 to my MacBook Air because there is no more storage space available. I want to make sure all my photos are not lost and that they do not return to the original devices because of the cloud. Can someone please help ?

    Connect your devices to the computer with the USB cable (one device at a time) and import the photos via iPhoto or Image Capture.
    If you have not changed any default settings on your computer, iPhoto will automatically launch when you plug in the device. Then follow the import prompts.

  • I just bought an Epson Stylus Pro 3880 and the printed images look yellow. I calibrate my MacBook Pro monitor with a ColorMunki Display. I want to make sure my Lightroom print settings are correct.

    I just bought an Epson Stylus Pro 3880 and the printed images look yellow. I calibrate my MacBook Pro monitor with a ColorMunki Display. I want to make sure my Lightroom print settings are correct.

    This what I have been trying......  Maybe my eyes are screwed up or don't understand the process....
    What I have been trying to do is squint and make the apple disappear by moving the sliders around in each step. Is that correct?

  • I need to delete all my pictures off of my iPhone because I have run out of storage.  I have downloaded all pics to my mac but is my entire camera roll backed up on iCloud as well? I just want to make sure before I delete them from the phone.

    I need to delete all my photos off my iphone because I have run out of local storage.  I have synced with my Mac but also wanted online backup.  Are all my photos from the camera roll uploaded to iCloud?  I just want to make sure I can retrieve them after I erase from the phone and in case my Mac crashes.

    Import photos through iPhoto. (You will prompt to delete from iPhone when import competes).
    Backup your Mac. (At least the iPhoto Library)
    Backup to iTunes.
    Backup to iCloud. (Check in Settings>iCloud>Storage and Backup>Manage Storage>your device name>Camera Roll ON).

Maybe you are looking for