Use of super

Hi all,
I have some questions on the use of super keyword.
1, Why super cannot be used to assign the super object to an instance in current object. I tried this
Class a
Class b extends a
in b
a var = super;
2, Is it possible to access the super class of a super class
a , b extends a, c extends b.
from c
super.super.getClass();
Antony Paul

1) Because it's not really a separate object. You can do this in b:
a var = this;
Since b extends a, any object that is a b is also an a.
2) Yes, but not that way. You can't chain supers together.
Class thisClass = this.getClass(); // c
Class superClass = this.getClass().getSuperclass(); // b
Class superSuperClass = this.getClass().getSuperclass().getSuperclass(); // a
or
Class thisClass = this.getClass(); // c
Class superClass = thisClass.getSuperclass(); // b
Class superSuperClass = superClass.getSuperclass(); // a

Similar Messages

  • HT1338 how do i load windows 7 on a mac air using the super drive?

    How do I load windows 7 on a Mac Air using the super drive?

    You use Boot Camp to partition the SSD in the Air, download the Win 7 Support files from Apple (part of the boot camp process), save them to a USB thumb drive, have the USB superdrive connect to the Air with the Win 7 install DVD in the drive. Once partitioned the system will reboot and start the Win 7 install.

  • HT2801 I understand there is a way to use my Super Drive with my PC.  However, it requires a System OS Disk.  Which I never received.  Can you help me with this?

    I understand there is a way to use my Super Drive with my PC.  However, it requires a System OS Disk.  Which I never received.  Can you help me with this?

    Rick6812 wrote:
      I'm using Windows 8.1. 
    I do not know what you mean by a Windows 8.1.  Please clarify.
    The Apple superdrive is designed to be used with the following Macs.
    It will not work with any other Mac unless you perform this modification;
    http://www.tuaw.com/2012/04/02/use-the-macbook-air-superdrive-with-any-almost-ma c/
    Are you trying to get it to work with a PC? 
    Ciao.

  • Can anyone tell me where i can get a new or used sony super drive dwu10 678-0429b in the UK, for my flat panel i mac g4  model no m9168lla , or  is there  any other compatable drives i could fit

    can anyone tell me where i can get a new or used sony super drive dwu10 678-0429b in the UK, for my flat panel i mac g4  model no m9168lla , or  is there  any other compatable drives i could fit

    Try eBay. You do occasionally see that old model advertised there.

  • Use of super keyword

    Hi all , iam new to java . plz tell me what is use of super keyword

    You might read the Managing Inheritance part of the Learning the Java Language tutorial.

  • Use of "super" key word in abap oops...

    Hi,
      Can any one explain me what is the use of ' super ' key word in abap oops. excluding super class.
    With Regards,
    M.S.Amirtharaj Vijay.

    Vijay,
    please read the sap documentation or f1 help
    Thanks
    Bala Duvvuri

  • Using the Super Word in a tutorial

    ive created two classes:
    public class Polygon
    int sides;
    double area;
    public Polygon()
    System.out.println("Inside no-arg constructor");
    public String NumberOfSides()
    System.out.println("The Number of Sides = " + sides);
    return sides;
    public String toString()
    System.out.println("Inside Polygon toString")
    String rep = "Sides" + sides + "area" + area;
    return rep;
    public Polygon(int s)
    sides = s;
    System.out.println("Inside One-Arg Constructor");
    public class Triangle extends Polygon
    int base;
    int height;
    public Triangle(int b, int h)
    base = b;
    height = h;
    The tutorial i am using says, 'Add a constructor to Triangle that takes in two int's for base and height. The constructor needs to use super() to invoke the constructor in Polygon, passing in 3 for the number of sides. Print out the message "Inside Triangle Constructor"
    as you can see i've created the triangle constructor which takes in the two int's but i am unsure how to use the super keyword to use the constructor within the polygon class to pass in 3 as the number of sides.
    can someone help me in solving this problem.
    Thanks
    Richard.

    if i was to change the order to that would it not
    take the NumberOfSides() and the toString() methods
    out of the no-argument constructor?You cannot put methods inside methods.
    That makes no sense in Java.
    i deliberately
    put them there because i only want them for the
    no-arg constructor. or must methods be seperate
    entities from constructors?Yes.
    And in fact, you have 2 more problems:
    your "sides" and "area" variable are uninitialized
    if people use your "no-arg" constructor,
    so the compiler will complain.
    You need to assign them some value in your constructor
    (perhaps "slides=0; area=0;")

  • Can I use a super drive double layer in my ibookG4?

    I have a 12 inch G4 iBook with the following specifications:
    Max OS X version 10.4.11
    Machine Name:          iBook G4
      Machine Model:          PowerBook6,5
      CPU Type:          PowerPC G4  (1.1)
      Number Of CPUs:          1
      CPU Speed:          1.2 GHz
      L2 Cache (per CPU):          512 KB
      Memory:          768 MB
      Bus Speed:          133 MHz
      Boot ROM Version:          4.8.7f1
      Serial Number:          4H******S87
    I want to upgrade the optical drive combo I have for a super drive double layer to record movies, music and learn to use properly  IDVD function.
    Also I would be interested to upgrade my operation system to snow leopard, Do I need to change the CPU speed as well? and I want to change the Memory to 1 GB. Should I get specific memory card to get 1GB? look forward to hear from you.
    Fernando
    <E-mail Edited by Host>

    The matter of obtaining a retail or replacement install DVD for Leopard 10.5
    can be elusive; some say they'd been able to call AppleCare or Sales Support
    US (two different 800 numbers, in Apple site) and for a fee of about $17, get
    a white label full install DVD for Leopard 10.5; also said to be available, was
    a white label DVD for Tiger 10.4. {These may or may not still be available;
    the kicker here, was some who called over the past year did get them, others
    who called later did not. Then even later on, others were able to get them.}
    This topic has come up a few times in ASC discussions, even early this year
    with posts in these threads with contact phone numbers to try & order discs.
    And at this moment, I do not have those numbers available to include here;
    nor do I know if I did, if the persons who may answer would be able to answer
    the question of availability themselves. Appears the answer has changed
    depending on who you are able to talk to, there at Apple.
    Since those of us who answer these discussions do not know policy nor do
    we represent Apple corporate, the results of any finding can be hit & miss.
    About browsers. Some exist that are custom builds for PowerPC Mac and
    there are some limits due to the nature of the volunteer efforts behind them.
    Of them, note of these some only work in OS X 10.5.8; a few offer an older
    OS 9 version (see icab site for a classic pre-X version.)
    •TenFourFox - 7450 ("G4e" - see DL link)
    http://www.floodgap.com/software/tenfourfox/
    http://sourceforge.net/projects/tenfourfox/files/24.4.0/TenFourFox7450-24.4.0.ap p.zip/download
    •iCab - shareware - runs free w/ small limitation
    http://www.icab.de/dl.php
    •SeaMonkey-for-PPC (OS X 10.5)
    http://sourceforge.net/projects/seamonkey-for-ppc/
    For my PPC G4 Macs, which run 10.5.8, I have these three browsers, and
    also the Safari browser of the vintage; you can use Safari to set a different
    browser as 'default' to the system, so a general browser launch triggers a
    different browser than Safari, another one will take its place. I also have
    an older Opera browser 10.63 that works, but is not supported w/ updates.
    So regarding the purchase of retail label (not grey from a machine series)
    DVD for a full install Mac OS X Leopard 10.5, an answer may exist, but
    I do not have the details; nor do I know of some are workable answers.
    And the discs said to be offered were either vintage replacements so a
    caller would need a serial number, to match; or were white label installer
    versions for a wider range of machines, not just one built model. So there
    is some matter of what they are, and if what you want may really exist!
    Some persons had looked into amazon or other possible sources, but if
    a seller misrepresents their product, you can't really use what won't work.
    You may be able to get old stock unused retail Leopard DVDs, ? online.
    {Oh, if you have some favorite classic applications from OS 9.2.2 & before
    you should consider a clone of Tiger 10.4.11 system with Classic, so you
    can later boot the computer from there, in order to run those old applications.
    Leopard does not support Classic in OS X. A backup hard disk drive with
    its own power supply, and with oxford-type chipset, can be used for clones.}
    Anyway, I thought to add the browser list; and a few add-ons from FireFox
    will work with TenFourFox. I use one that makes the first open browser
    window not have a tab. TenFourFox 17 had no tabs by default, now v.24
    has tabs. I prefer separate windows so I can drag-drop between them and
    do multiple searches or have other topics open at once. Or run two browsers.
    Hopefully this helps somewhat.
    Good luck & happy computing!

  • The use of "super" in a constructor

    Hi,
    I am wondering what using "super();" in a constructor does. I've seen this used in may other people's code and I simply don't understand what that line would do.
    Thanks for your advice.

    the super class being that class which you have derived from.
    Example:
    Base Class
    public class Amphibian
    Amphibian();
    System.out.println("Constructor of Amphibian");
    public swims()
    //swim
    <b>SubClass</b>
    public class Frog extends Amphibian
    Frog()
    super(); // this calls constructor of Amphibian and will print out: Constructor of Amphibian to the console
    I hope this helps

  • Initializing instance variables in a constructor that are used by super()

    I have a class that extends a standard class (ie JButton, but it doesn't matter what class). The constructor takes a parameter that I set to an instance variable. There is an overloaded method of the standard class that needs to use the variable.
    My problem is that since I must call super() first, my instance variable is not yet set, so when my overloaded method is called by the constructor it is unable to see the paramater value. How can my method see this value?
    public class MyClass extends somejavaclass {
    MyClass(int x) {
    super();
    myInt = x;
    // This overrides something in somejavaclass and is called by the constructor
    public void aJavaMethod() {
    // do some logic with myInt, but it has not been set to my paramater value
    int myInt;
    }

    If the variable in question is an object reference,
    you could compare it to null. A true result would tell
    you that it hadn't been initialized yet, and you could
    write code to behave accordingly (for example calling
    the init() method to do the initialization).That's a good solution but what if the instance in question is set in the sub-classes constructor?
    This is a very annoying feature of Java, and one that
    I have had to work around on several occasions. And as
    far as I'm concerned it's an unnecessary feature: why
    shouldn't a class be able to initialize its variables
    before it calls the superclass's constructor? Other OO
    languages permit that.I've wondered this also. I'd always assumed it was a way to make sure the super-class was completely initialized before anything tries to use it esp. to make sure the Object() constructor is finished before anything else happens.
    How is this dealt with in C++ or does it just leave open potential for errors?

  • Using Nikon Super Cool Scan 8000ED through 800/400 firewire converter

    I have a Nikon Super CoolScan 8000 ED that I am trying to use with my iMac quad-core i5 running Snow Leopard. The only connection coming out of the scanner is Firewire 400. I purchased a Firewire 400/800 adapter and plugged it into the Firewire 800 port on the iMac. There is no response from the computer, it doesn't even seem to be able to detect that the scanner is connected at all.
    I have downloaded the driver from Nikon, and it appears to be installed on the computer.
    Any suggestions? -J.

    People have had a lot of problems with FW400/FW800 plug adapters. Better to use a cable with a 6-pin FW connector on one end and 9-pin FW connector on the other. Here is the cable I use and it works perfectly.
    Make sure you can 'see' the scanner in +System Profiler > Hardware > Firewire.+ If the scanner shows up there, then any scanning app should be able to access the scanner.
    Also, what driver did you download from Nikon? There is no driver needed for this scanner on OS X. Did you download & install Nikon Scan (4.0 or 4.0.2)? You don't need it - it's not a driver, it's a scanning app and it was never updated for Snow Leopard; only a lucky few seem to have been able to get NikonScan working on Snow Leopard.
    Download a copy of Vuescan - it works great with the Nikon scanners.

  • 6500 running in native - which memory is used? SUP or MSFC?

    Hi,
    I have looked at memory requirments for IOS images.
    When minimum DRAM and flash requirments are listed, which memory is this? Because the switch in running in native IOS it could be either?
    I'm fairly sure that the flash is use id the Supervisor flash, but I'm not sure about the DRAM.
    Does anyone know??
    Thanks,
    Dave

    Depending on if you are dealing with 12.1E or 12.2S code, there are different requirements.
    For example, for the sup2:
    http://www.cisco.com/univercd/cc/td/doc/product/lan/cat6000/122sx/ol_4164.htm#wp2561255
    256MB is required for both the supervisor and the MSFC2 if running 12.2S code.
    For 12.1E code on the sup2:
    http://www.cisco.com/univercd/cc/td/doc/product/lan/cat6000/12_1e/ol_2310.htm#wp1408120
    128MB is recommended for the sup and 256MB for the MSFC2
    Specific requirements for the other sups are also documented in the Release-notes. If you are going to have a large number of routes on the switch, it's recommended to have the same amount of memory on the supervisor and the MSFC as both processors keep their own copy of the FIB table in their local memory. Memory recommendations for various thresholds of route table sizes are also documented in the release notes.
    HTH,
    Bobby

  • Using LG Super Multi Blue BE14 Blu-Ray Writer on Mavericks OS

    I have read online reports of persons successfully using an LG Super Multi Blue BE14 Blu-Ray writer on an iMac with recent OS X, even though LG advertises support only for Windows OS. They said it recognized the unit automatically when pluged into the USB port
    It did not work for me. Perhaps my USB is too slow, since the default for the burner is USB 3.0. Any truth to Mavericks not supporting external DVD players/burners?

    Interesting because it says that model is only compatible with
    Windows 8
    Windows 7
    Windows Vista
    Windows XP
    -- Funny how things work !!

  • How to use usb super drive at mcbook pro with retina

    I had just bought a mcbookpro with retina on-line. I bought a USB super drive as well. I don't know how what button i'll be using to operate the usb super drive. Can anyone help?

    If you've a CD with Microsoft Office on it, all you need to do is double-click the installer program on the CD. If you don't see the CD mounted on your Desktop, go to Finder>Preferences>General, and tick the box that says "CDs, DVDs, and iPods" under "Show these items on the desktop".
    After you've finished installing Office, simply drag the disc to the Trash and it will eject (I don't have a Retina display model, so I'm not sure if there's an optical disc eject button next to the F12 key or nor - if there is, you can use that as well).
    Hope this helps.
    Clinton

  • When should a subclass have its own fields and when should it use its super

    When should a subclass have its own fields and when should it use its superclass' fields?
    Hi, thank you for reading this post!
    Let me use a specific example to ask my question.
    public class BankAccount {
         private double accountBalance;
         public double getBalance() {
              return this.accountBalance;
    public class SavingsAccount extends BankAccount {
         private double accountBalance;
         public double getBalance() {
              return this.accountBalance;
    }In the bank account example, both BankAccount and SavingsAccount will have a method getBalance(). Therefore, they
    both require a account balance field. My question is since getBalance() for both classes will perform the exact same
    operation, when should I omit declaring the getBalance() method and the accountBalance field in the subclass, and
    when should I include them?
    My own thought is when we never have to instantiate a superclass object (e.g. an abstract class), then we place
    common fields in the abstract superclass and have subclasses access these fields via protected getter/setters to
    access the superclass' fields. This is the principle of reuse.
    But when you do need to instantiate a superclass and the superclass does need to maintain its own fields, then
    I would need to duplicate the accountBalance field and getBalance() method in the subclass.
    Is my thinking correct or incorrect?
    Thank you in advance for your help!
    Eric
    Edited by: er**** on 22-Aug-2011 20:19

    er**** wrote:
    If SavingsAccount inherit BankAccount.getBalance()...getBalance() would return BankAccount's accountBalance. This is NOT the correct result we want.Actually, I think it's precisely what you want.
    We want getBalance() to return BankAccount's accountBalance when we use a BankAccount object, and SavingsAccount's accountBalance when we use a SavingsAccount object.I seriously doubt that. I think you're confusing a BankAccount with a Customer, who can have more than one account.
    In every system I've ever seen, a SavingsAccount IS-A BankAccount - that is to say, it's a genuine subtype. Now, it may well contain other fields ('interest'?) that a normal account wouldn't, but 'balance' ain't one of them.
    Winston

Maybe you are looking for