Newbie inheritance question

I have created a base class which implements cloneable (and I know the clone function works). I have also created two classes derived from the base class (which don't have cloneable implemented).
Is it possible to "clone" the base class components of both derived classes. Here is what I mean
//both derived from class1 which implements clone()
class2 c2
class3 c3
c2 = c3.clone(); //I just want to clone the c1 member variables
How do you go about doing this correctly.

You won't be able to do c2 = c3.clone(), because c3.clone() will return a reference to an instance of class3, which is not a subclass of class2.
The correct first step of the clone() method is to call super.clone(), which will give you an instance of the same class as the object you're cloning, with all the fields set to the same values. You can then change some fields' values before returning the result.

Similar Messages

  • General place for newbie datamodeler questions?

    With the production release of SQL Developer Data Modeler I'd assume that this forum will draw a bunch of new users. Is there a better place to ask some pretty simple, newbie like questions that won't bother the more seasoned members?
    For instance, I am working in a Rails environment, which has some stringent naming conventions, one of which is that all of the primary key columns are numeric and called "id", with the foreign key linked columns called <table_name>_id.  When engineering a logical model to a relational model, the added foreign key columns are all "id#".  Is there a way I can define a naming rule to keep me from having to redo the relation column names?
    Also, we have a standard set of columns (mostly Rails related) which appear in every table. Can I define a generation rule which automatically includes these tables?
    Thanks

    Thank you. I will try changing that setting.
    IS there a setting which tells the relational model to automatically create pk and fk indexes? I haven't seen one, and manually setting them up is a tedious task. --sw                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Newbie script question... consecutive numbers with update.

    complete newbie type question... this is also my first post.  ( I am using CS3)
    does anyone have a script which can make it so I can add numbers into the text consecutively.
    for example, if this is my text "the big fat dog sat on the very wide mat, but was then displaced by a unfriendly cat."
    and I wanted to place a number 1, number 2, 3, etc at points in the text so it read, "the big fat dog1 sat on the very wide mat2, but was then displaced by a unfriendly cat3." but later wanted to add another number and have later numbers update themselves, so the text then said, "the big fat dog1 sat on the very wide mat2, but was then displaced3 by a unfriendly cat.4".
    by inserting the three, the previous three became four.
    Has anyone got something which might be useful in this regard.
    Many thanks
    Steve

    i wanted to avoid footnotes as they leave a bar at the bottom of each page.
    i wanted a script to do something similar to footnotes but not much further.
    does anyone have just a simple script that can do what I asked?
    Steve

  • Newbie XSan question - authenticating a computer from XSan Admin

    Hello - I have a very newbie XSan question!
    I have 2 computers that connect to an XSan. 1 I am having no problems with. The other I am unable to connect with.
    When I look in XSan Admin the 2nd computer (the one that is not working) is not authenticated.
    So I click on it and choose Authenticate. I enter what I know is an Admin username and password for the computer I am attempting to connect. The dot next to the computers IP turns green with 3 dots in it and then it turns gray again. It just does not connect.
    What is the problem?
    Is it licensing?
    Thanks
    Taj

    You need a different license ID for each machine, plus the admin machine. Do you have that?

  • This Newbie Has Questions

    Hi there. I am a newbie to Apple. I purchased the iBook last month and of course, when the MacBook (which had the features I wanted) came out, I rushed out and got one and I'm very pleased with my purchase - but I have a few "newbie" questions:
    1) Printing on a PC based Linksys seems to be a nightmare. I can't get anything printed on the shared HP 2600N and HP1012 printers. I literally have to disconnect them from the PC and plug the USB directly to my MacBook to print. It seems like there should be a better, easier and MacFriendly way of doing this - anyone have an easy solution?
    2) I'm going to purchase Windows XP so I can run my windows programs on this computer. Does anyone have any pre-installation advice?
    3) I have a blackberry device that worked fine with my iBook, but does not work with my MacBook - any suggestions or is there a software compatibility patch?
    4) I transferred everything from my old Mac to my new Mac with no problem. How can I migrate my contacts from Entourage to the Address Book?
    5) I notice that sometimes the MacBook "stalls" or doesn't work fast in some functions...is it just me - I expect the machine to jump quickly...but sometimes I get that annoying pinwheel when opening programs.
    Thanks for your help!

    1) Printing on a PC based Linksys seems to be a
    nightmare. I can't get anything printed on the
    shared HP 2600N and HP1012 printers. I literally
    have to disconnect them from the PC and plug the USB
    directly to my MacBook to print. It seems like
    there should be a better, easier and MacFriendly way
    of doing this - anyone have an easy solution?
    The problem is probably a driver issue.
    Printing to a printer on a XP PC from a Mac running 10.4.x
    http://www.ifelix.co.uk/tech/3015.html
    You may need to use a third-party driver such as the HPIJS drivers or the Gimp-Print drivers, but this is not the case with all printers.
    2) I'm going to purchase Windows XP so I can run my
    windows programs on this computer. Does anyone have
    any pre-installation advice?
    Ensure you get a full version (not an upgrade version) and it comes with XP SP2 already.
    Do not install Boot Camp on a critical machine and make regular backups of your data, this is beta software and there are bugs and issues.
    5) I notice that sometimes the MacBook "stalls" or
    doesn't work fast in some functions...is it just me -
    I expect the machine to jump quickly...but sometimes
    I get that annoying pinwheel when opening programs.
    Are these Universal or PPC only applications?
    iFelix

  • Newbie wireless question (slightly off-topic)

    I didn't want to post this here as it's not entirely an Airport-specific question. I posted this to the iBook forums, but nobody there has answered so my apologies if this is not welcome here. (Any moderators can remove it if that's the case.)
    I've been using computers extensively for over a decade, but I'm a total newbie to wifi. I just set up a wireless network in my house and would appreciate some advice/feedback.
    My main concerns are whether or not my network is reasonably secure. I know there is no such thing as perfect security, but I don't know if what I've done is good enough or not.
    I don't have an Airport base station, but I do have a D-Link Airplus G and an Airport card in my iBook. I have WEP set up on the router and I have enabled MAC filtering, listing only my desktop and my iBook, excluding all others from the network.
    I'm fairly certain that nobody in my neighborhood is going to get into my machines this way or be able to sniff my network data stream, but am I right in assuming that nobody can "piggyback" on my Internet connection too? Presumably, if everyone but my own machines are MAC-filtered and kept out, then the Internet connection is also protected. Is that how it works?

    WEP and MAC filtering are better than nothing, but you can do better. These are my suggestions:
    1. Use WPA with a pre-shared key (PSK) and TKIP encryption on your Netgear router, along with an alphanumeric passphrase of at least eight characters not found in any dictionary. The equivalent setting on your Mac is "WPA Personal". Unlike WEP security (which an expert can crack in under half an hour), WPA security is currently unhackable by any practical means as long as you use a non-dictionary passphrase. One last point - WPA security requires all your wireless Macs to be running MacOS 10.3 or newer.
    2. MAC filtering is (these days) essentially useless as a wireless security method. Using "packet sniffing" of traffic on your wireless network to find out what MAC addresses are used by computers on your network, and a PC that allows its MAC address to be cloned so that it is identical to the MAC address of one your own wireless computers (which is possible with most PC wireless network adapters) even an amateur hacker can defeat MAC address filtering in minutes.
    By the way - I don't think your posted message here is off topic. In my opinion, the Airport discussion forums are the best place to post any questions related to usage of wireless networks. Questions of this nature are virtually never specific to any Mac model.

  • Constructor Inheritance Question

    Here's a quote from the Java Tutorials at http://java.sun.com/docs/books/tutorial/java/javaOO/objectcreation.html :
    "All classes have at least one constructor. If a class does not explicitly declare any, the Java compiler automatically provides a no-argument constructor, called the default constructor. This default constructor calls the class parent's no-argument constructor, or the Object constructor if the class has no other parent. If the parent has no constructor (Object does have one), the compiler will reject the program."
    In order to fully understand this concept, I created two classes: a ClassParent and a ClassChild.
    public class ClassParent
        public static void main(String[] args) {
           ClassParent tester = new ClassParent();
    public class ClassChild extends ClassParent
        public static void main(String[] args) {
            ClassChild child = new ClassChild();
    }Both classes compiled successfully, which raised the following question:
    I understand that the ClassParent default constructor calls the Object's no-argument constructor.
    Does the ClassChild also call the Object's constructor once it realizes that the ClassParent does not have a no-argument constructor?
    And a somewhat non-related question:
    Seeing how ClassParent calls Object's no-argument constructor if it does not have one of its own, does it also extend the Object class?
    Edit: After running the following code, I realized that the answer to my last question is yes:
    public class ClassParent
        public static void main(String[] args) {
           ClassParent tester = new ClassParent();
           boolean test = tester instanceof Object;
           System.out.println(test);
    }Edited by: youmefriend722 on May 26, 2008 1:54 PM

    youmefriend722 wrote:
    I think I'm getting a basic grasp now but want to make sure that I'm not misunderstanding anything.
    Constructor inheritance:
    If a no-argument constructor is invoked but one isn't declared in that class, the superclass's no-argument constructor will be invoked. Well, sort of. If you invoke a constructor that doesn't exist, you get an error. Keep in mind that the invocation and the constructor may both be automatically supplied by the compiler, and that the compiler won't automatically create a no-arg constructor for a class if you define any constructors for that class.
    So if you don't define any constructors in a class, then a no-arg one is created automatically (at compile time) and (at runtime) when you instantiate that class, that no-arg constructor will try to invoke the superclass's no-arg constructor.
    But suppose you do define a constructor, one that takes an argument. Then if you try to invoke a no-arg constructor on that class, you'll get an error, and the superclass's no-arg constructor won't be invoked (because the error happens first).
    If the superclass does not have a constructor, then the superclass's superclass's constructor will be invoked.No. That never happens. Every class has a constructor (although it might have permissions which make it inaccessible, which is a whole other issue we'll worry about later).
    If the superclass does have a constructor but doesn't have a no-argument constructor, then there will be a compile-time error.Only if you try to invoke the no-arg constructor, which might happen implicitly. For example, if you write a superclass with a 2-arg constructor, and you write a subclass with a 1-arg constructor, and the 1-arg subclass's constructor invokes the superclass's 2-arg constructor, then there's no problem, even though in this example, the superclass doesn't have a no-arg constructor.
    Constructors in general:
    In every constructor, the superclass's no-argument constructor will be invoked if the none of the superclass's constructors are explicitly invoked.Yeah, I think that's right.

  • Newbie saving question in Illustrator

    I know this is a newbie question. I designed a logo in Illustrator. Is there a way to save just the logo for exporting into other applications (ie Pagemaker or Photoshop) without having the white artboard?
    Thanks
    Brad

    I don't know Pagemaker but with Photoshop I simply select all, copy and then paste in Photoshop - transparency will be maintained. If you paste as a Smart Object you retain the ability to edit the Illustrator artwork in Illustrator and update the PS file.

  • Dumb newbie hardware question! :)

    Hi folks,
    I'm new to the world of the blackberry and am just about to take the plunge with an unlocked sim-free BB Bold to use in the UK on Vodafone. I have read about the software differences between BIS and BES and would be going for a BIS set-up. My dumb newbie question is does the hardware come in BES and BIS versions or not?
    Many thanks in advance and feel free to mock my foolishness
    Solved!
    Go to Solution.

    hello, about BIS and BES it's explained on the website but it's clear that if someone sums it up for you it will be easier...
    so BES is a type of contract between a company and Blackberry. The company IT buy computers, put Blackberry servers, and buy a fleet of Blackberry Devices for the people in the company to use them and get email through the Blackberry servers.
    BIS is a type of contract between a common person and a carrier. The consumer goes to the carrier, and buys a Blackberry device, and a BIS plan that will enable him/her to :
    phone/sms/mms
    receive emails that have been configured on the BIS site
    do data things if you subscribe to (like browse the web)
    You can buy a Blackberry from a carrier that has a deal with RIM (the company that sells Blackberries). Or you can buy a blackberry alone, and then go and contact a carrier that has a deal with RIM.
    phone/sms/mms
    receive emails that have been configured on the BIS site
    do data things if you subscribe to (like browse the web)
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • NEWBIE SOA Question:Appl Development for SOA

    This question may have been answered elsewhere; if so, my apologies.
    As a newbie to SOA, I am trying to wrap my head around the question of how app. development for SOA differs from traditional models. For example, non-SOA environments there are few external considerations when coding a process,
    but in SOA environments, I understand everything is a service.
    Can someone provide a few code snippets as to how they would look in each environment?
    I have read through several documents on SOA and have done the SOA tutorial, etc. but I have yet to see a side-by-side comparison of application code in SOA and non-SOA environments.
    How would an architect plan the translation and mapping of business objectives and functional requirements into a technical solution for SOA, architecting the SOA solution ?
    I would really appreciate any pointers (links to articles, etc.) in this direction. Thank you.
    Gordon

    Hello Gordon,
    SOA (Service Oriented Architecture) - as the name indicates, it's design is based on services. SOA is another integration technique which is used for small scale integration. SOA is an approach to have software resources in an enterprise available and discoverable on network as well defined services. Each service would achieve a predefined business objective and perform discrete units of work. The services are independent and do not depend on the context or state of the other services. They work within distributed systems architecture.
    Few links which may help you in understanding SOA and it's design patterns -
    http://blogs.oracle.com/jeffdavies/2008/10/architects_dictionary.html
    http://www.oracle.com/technology/tech/soa/mastering-soa-series/part1.html
    http://www.oracle.com/technology/tech/soa/mastering-soa-series/part2.html
    http://www.oracle.com/technology/tech/soa/mastering-soa-series/part3.html
    http://www.oracle.com/technology/tech/soa/mastering-soa-series/part4.html
    http://www.oracle.com/technologies/soa/docs/soa-bp-design-patterns-whitepaper.pdf
    http://www.oracle.com/technology/pub/articles/erl_soa_design_patterns_app_sequences.html
    http://www.oracle.com/technology/oramag/oracle/09-sep/o59architect.html
    http://www.oracle.com/technology/pub/articles/tech_arch.html#soa
    Regards,
    Anuj

  • Newb HD questions...?

    I'm a newb to HD and we've just got funding for a HD camera. The boss bought a Panasonic AG-HMC150P.
    The question is about recording mode, in "p" or "i". Currently it is set for 1080/60i, its top setting. But it has a 1080/30p too.
    Our products will be made to view on a TV screen ntsc, and a computer screen.
    Is the "i" setting the best for us? ie: is there any advantage in us using the 30p setting?
    Also, I have FCP6 and a colleague has FCP5 on a less powerful machine.
    Whats the best way to hand him newly captured HD footage? Is it to render it out using H264 on my machine before passing it over?
    We are hoping funding for software upgrade/machine will come soon for him.

    Well, the short answer is "i" (interlaced) is only for display on older CRT "tube" televisions. "p" (progressive) is for display on computers and flat screen televisions. Typically you should try to stay progressive these days. 60i can be useful if you are going to slow-mo any shoots.
    Do NOT convert your files to H.264 to send to another edit. H.264 is not a good codec for editing, use it for distribution of edited material only.
    For sharing with FCP5 on a slower computer, consider using DVCProHD.

  • Newbie audio question--help please...

    I recently recorded/captured video from Canon HV30 and unfortunately found that only Left audio channel was recorded..Right channel in non-existant. How do I duplicate the audio track from Left to Right so that both tracks are played in sync?
    I appreciate your help on this newbie question!

    When the left channel is filled you use the Fill Left effect
    The Fill Left effect duplicates the left channel information of the audio clip and places it in the right channel, discarding the original clip’s right channel information.
    Instead of putting the effect on each clip use the Audio Mixer.

  • Multiple inheritance question

    This just occurred to me. I read the other day that all classes inherit Object. So if I have a class defined as public class A {
    }and I call toString() on an instance of this class, I get Objects toString implementation (assuming it has not been overridden). OK, this I understand.
    Now if instead I havepublic class A extends B {
    }and I call toString() on A, assuming it is not overridden in either A or B, I will still get Objects toString method. My question is, does A still extend Object, or does it inherit the fact that B extends Object? And what happens if I override toString() in B - what will I get if i call toString on an instance of A?

    java.lang.Object is at the root of all class inheritance hierarchies in Java. Therefore, all classes inherit from java.lang.Object, either directly or indirectly.
    When you call a method on an object of class Foo, Foo's inheritance hierarchy is traced starting with Foo and going all the way back to java.lang.Object, looking for an implementation of the method. The first implementation encountered is the one that gets used. So in your example calling toString on an instance of class A will result in B's toString method being executed.
    Hope this makes sense.

  • A newbie first question: fpga synchronous input

    Hi all
    this is my first time to send a question at this forum
    it is also the first time to use Labview, I am totally newbie
    My problem is:
    I have Xilinx Spartan 3A FPGA with a design runs at 10 MHz " derived from the 50 MHz of the On-board clock"
    I want to test my design by appling inputs to the FPGA and watching the output
    so how to apply predefined synchronous inputs that are synchronized to the my design clock
    thanks in advance

    Good Afternoon msaleh87,
    What supporting hardware are you using with your Xilinx Spartan 3A FPGA?  The only NI hardware that the Xilinx Spartan 3A FPGA is found in are the sb-RIOs and the cRIO-9072 and cRIO-9074.
    What Xilinx FPGA Chips Are Used by National Instruments RIO
    Devices?
         http://digital.ni.com/public.nsf/allkb/ED6FC9CF7B983CFD86256DCE0072E313?OpenDocument
    Please elaborate on what you are trying to accomplish with this project.  Also, please give some more details (such as source, speed, type, etc.) of your predefined synchronous inputs.
    Regards,
    Charlie Piazza
    Staff Product Support Engineer, RF
    National Instruments

  • For loops & inheritance question

    I am trying this exercise dealing w/inheritance. I enter at command line a random number of c's, s's and m's. for checking,savings and money market. I then parse the string and check for the character. From there I create one of the accounts. then I am supposed to make a report that displays the past 3 months activities. the first account created gets 500 deposit the from there each account after the first gets an additional 400. so it would be: 500,900,1300,etc. Here is what I have so far, but the report part is where I can't figure out exactly how to go about solving it. Thanks in advance.
    public static void main( String args[] ){
         int intDeposit = 500;
         char charTest;
         Object [] objArray = new Object[args[0].length()];
         for ( int j = 0; j < 3; j ++ ){                        System.out.println( "Month " + ( j +1 ) + ":" );
             for( int i = 0; i < args[ 0 ].length(); i ++ ){
              charTest = args[ 0 ].charAt( i );
                         if (charTest == 'c' ){
                  BankAccount at = new  CheckingAccount( intDeposit );
                  objArray=at;
              else if( charTest == 's' ){
              BankAccount at = new SavingsAccount( intDeposit );
              objArray[i]=at;
              else if( charTest == 'm' ){
              BankAccount at = new MoneyMarket( intDeposit );
              objArray[i]=at;
              else{
              System.out.println( "invalid input" );
              }//else
              intDeposit += 400;
              System.out.println();
         }//for j
         for (int counter = 0; counter < objArray.length; counter ++ ){
              System.out.println( "Account Type: " +
                        objArray[counter].toString() );
              System.out.println( "Initial Balance: " +
                        (BankAccount) objArray[counter].getCurrentBalance() );
         System.out.println( "TotalDeposits: " + objArray[counter].getTotalDeposits() );
         System.out.println();
         }//for i
    }//main
    }//TestBankAccount.java\

    The only thing I think is wrong is the following line:
    System.out.println( "Initial Balance: " +                    (BankAccount) objArray[counter].getCurrentBalance() );
    Should be:
    System.out.println( "Initial Balance: " +                    ((BankAccount) objArray[counter]).getCurrentBalance() );

Maybe you are looking for