Some serialization confusions........please help

confusion 1:
import java.io.*;
public class SerializeDog {
public static void main(String[] args) {
Collar c = new Collar(3);
Dog d = new Dog(c, 5);
System.out.println("before: collar size is "+ d.getCollar().getCollarSize());
try {
FileOutputStream fs = new FileOutputStream("testSer.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(d);
os.close();
} catch (Exception e) { e.printStackTrace(); }
try {
FileInputStream fis = new FileInputStream("testSer.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
d = (Dog) ois.readObject();
ois.close();
} catch (Exception e) { e.printStackTrace(); }
System.out.println("after: collar size is "+ d.getCollar().getCollarSize());
class Dog implements Serializable {
private Collar theCollar;
private int dogSize;
public Dog(Collar collar, int size) {
theCollar = collar;
dogSize = size;
public Collar getCollar() { return theCollar; }
class Collar implements Serializable {
private int collarSize;
public Collar(int size) { collarSize = size; }
public int getCollarSize() { return collarSize; }
//output is before 3,after 3In the example above dog use instance variable of type collar which when is not serialized throws notserialized exception. So how do we serialize classes we don?t have access to coding for e.g. if here we did?nt have access to collar class.
confusion 2:
import java.io.*;
class SuperNotSerial {
public static void main(String [] args) {
Dog d = new Dog(35, "Fido");
System.out.println("before: " + d.name + " "+ d.weight);
try {
FileOutputStream fs = new FileOutputStream("testSer.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(d);
os.close();
} catch (Exception e) { e.printStackTrace(); }
try {
FileInputStream fis = new FileInputStream("testSer.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
d = (Dog) ois.readObject();
ois.close();
} catch (Exception e) { e.printStackTrace(); }
System.out.println("after: " + d.name + " "
+ d.weight);
class Dog extends Animal implements Serializable {
String name;
Dog(int w, String n) {
weight = w; // inherited
name = n; // not inherited
class Animal { // not serializable !
int weight = 42;
//output
before: Fido 35
after: Fido 42And in this example animal is not serialized so it takes default values when it desrialized for animal instance variable. So how the actual state of object gets saved at all?
Only the current serialized object has its state saved not its perant nor any other classes. So in actual programming wouldn?t it become difficult to serialze and desiralize as even a simple program can have n type of objects not related by inheritance.

confusion 1:
package Basics1;
import java.io.*;
public class SerializeDog {
    public static void main(String[] args) {
        Collar c = new Collar(3);
        Dog d = new Dog(c, 5);
        System.out.println("before: collar size is "+ d.getCollar().getCollarSize());
        try {
            FileOutputStream fs = new FileOutputStream("testSer.ser");
            ObjectOutputStream os = new ObjectOutputStream(fs);
            os.writeObject(d);
            os.close();
            } catch (Exception e) { e.printStackTrace(); }
        try {
            FileInputStream fis = new FileInputStream("testSer.ser");
            ObjectInputStream ois = new ObjectInputStream(fis);
            d = (Dog) ois.readObject();
            ois.close();
            } catch (Exception e) { e.printStackTrace(); }
        System.out.println("after: collar size is "+ d.getCollar().getCollarSize());
class Dog implements Serializable {
    private Collar theCollar;
    private int dogSize;
    public Dog(Collar collar, int size) {
        theCollar = collar;
        dogSize = size;
    public Collar getCollar() { return theCollar; }
class Collar implements Serializable {
    private int collarSize;
    public Collar(int size) { collarSize = size; }
    public int getCollarSize() { return collarSize; }
}In the example above dog use instance variable of type collar which when is not serialized throws notserialized exception. So how do we serialize classes we don?t have access to coding for e.g. if here we did?nt have access to collar class.
package Basics1;
import java.io.*;
class SuperNotSerial {
    public static void main(String [] args) {
        Dog d = new Dog(35, "Fido");
        System.out.println("before: " + d.name + " "+ d.weight);
        try {
            FileOutputStream fs = new FileOutputStream("testSer.ser");
            ObjectOutputStream os = new ObjectOutputStream(fs);
            os.writeObject(d);
            os.close();
            } catch (Exception e) { e.printStackTrace(); }
        try {
            FileInputStream fis = new FileInputStream("testSer.ser");
            ObjectInputStream ois = new ObjectInputStream(fis);
            d = (Dog) ois.readObject();
            ois.close();
            } catch (Exception e) { e.printStackTrace(); }
            System.out.println("after: " + d.name + " "+ d.weight);
class Dog extends Animal implements Serializable{
    String name;
    Dog(int w, String n) {
        weight = w; // inherited
        name = n; // not inherited
class Animal { // not serializable !
    int weight = 42;
}And in this example animal is not serialized so it takes default values when it desrialized for animal instance variable. So how the actual state of object gets saved at all?
Only the current serialized object has its state saved not its perant nor any other classes. So in actual programming wouldn?t it become difficult to serialze and desiralize as even a simple program can have n type of objects not related by inheritance.
i think it is pretty formated now

Similar Messages

  • I have installed the new up to date itunes which i can open on my PC, however when i connect my ipad or iphone i get an error saying i cannot use the device as the require software isn't installed?? I'm very confused please help......

    I have installed the new up to date itunes which i can open on my PC, however when i connect my ipad or iphone i get an error saying i cannot use the device as the require software isn't installed?? I'm very confused please help......

    Let's try a standalone Apple Mobile Device Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of why it's not installing under normal conditions.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/
    Right-click the iTunesSetup.exe (or iTunes64setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleMobileDeviceSupport.msi (or AppleMobileDeviceSupport64.msi) to do a standalone AMDS install.
    (If it offers you the choice to remove or repair, choose "Remove", and if the uninstall goes through successfully, see if you can reinstall by doubleclicking the AppleMobileDeviceSupport.msi again.)
    Does it install (or uninstall and then reinstall) properly for you? If so, can you get a normal iTunes install to go through properly now?
    If instead you get an error message during the install (or uninstall), let us know what it says. (Precise text, please.)

  • I downloaded a song on iTunes, it won't play (it's name is grey), it shows up in purchased and says "play", but it won't play, I can't delete it, and I can't re-download it.....this is confusing please help!!

    I downloaded a song on iTunes, it won't play (it's name is grey), it shows up in purchased and says "play", but it won't play, I can't delete it, and I can't re-download it.....this is confusing please help!!

    Hello CTGame,
    Welcome to Apple Support Communities.
    It sounds like there’s a grayed out song in your iTunes library that can’t be played or downloaded again like other past purchases. Try taking a look at the article linked below and verify the computer is authorized to play that content.
    How to troubleshoot iTunes Match - Apple Support
    Songs appear to be missing
    Songs containing DRM (Digital Rights Management) might not appear in iCloud, or might appear grayed out. This can occur if your computer is not authorized to play that content. Try authorizing your computer, then manually update iTunes Match. To determine what Apple ID your computer needs to be authorized for to play a specific song:
    Locate and select the song in your iTunes library.
    Choose File > Get Info.
    In the Summary tab, locate the Account Name field in the right column. Write it down.
    Click OK.
    Choose Store > Authorize this Computer.
    Type in the account name from the Summary field and enter its password. Click Authorize.
    Choose Store > Update iTunes Match.
    So long,
    -Jason

  • My iPhone 4S screen flash all the time. Like if its locked it turns on. I think some notification pop for some msc. Please HELP!

    My iPhone 4S screen flash all the time. Like if its locked it turns on. I think some notification pop for some msc. Please HELP!

    Basics from the manual are restart, reset, restore.
    Have you tried each of these?

  • After ios 5 update my iphone 3gs stopped writing some letters (t, f, c) and some 5 number. please help. !

    after ios 5.0.1  update my iphone 3gs stopped writing some letters (t, f, c) and some "5" number. please help. !
    and the unlock slider is not working properly, i have to slide many times to open the phone.

    Same problem.

  • I work on the CompactRIO 9068 that the password is lost for some time. Please help me to reset it, for finish my end of study project. Thank you,

    I work on the CompactRIO 9068 that the password is lost for some time.
    Please  help me to  reset it, for finish my end of study project.
    Thank you,

    but the page of ni support does not work:
    https://sine.ni.com/srm/app/newrequest
    and I have the recovery.cfg file from NI with this steps :
    1.        Copy the recovery.cfg file, found in the zip folder attached at the bottom of the email, to the thumb drive. 
    2.        With the cRIO device powered off, plug in the USB drive to the controller.
    3.        Hold down the reset button while powering on the controller.  Continue holding the reset button until the status light turns on, then release the reset button.
    4.        Wait for the controller to boot.  This should take less than a minute.
    5.        Check that the password has been reset to the default. (you will still be prompted for a password even if the default is blank)
    6.        Reinstall software to the controller. Using the USB reset will leave the system in a state where it is unable to run LVRT
      I have followed the procedure as mentioned 
    Result: the LED "Status" is permanently blinking.
    Would you please provide as with another alternative so that we can fix this issue.

  • Can anyone tell me how to get rid of tlb search? it unfortunately entered into my mac. Whenever I use safari, a pop-up window opens with some ads. Please help me to find a way to remove this malware.

    Can anyone tell me how to get rid of tlb search? It unfortunately entered into my mac. Whenever I use safari, a pop-up window opens with some ads. Please help me to find a way to remove this malware.

    You installed the "DownLite" trojan, perhaps under a different name. Remove it as follows.
    Malware is constantly changing to get around the defenses against it. The instructions in this comment are valid as of now, as far as I know. They won't necessarily be valid in the future. Anyone finding this comment a few days or more after it was posted should look for more recent discussions or start a new one.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    /Library/LaunchAgents/com.vsearch.agent.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item named "VSearch" selected. Drag the selected item to the Trash. You may be prompted for your administrator login password.
    Repeat with each of these lines:
    /Library/LaunchDaemons/com.vsearch.daemon.plist
    /Library/LaunchDaemons/com.vsearch.helper.plist
    /Library/LaunchDaemons/Jack.plist
    Restart the computer and empty the Trash. Then delete the following items in the same way:
    /Library/Application Support/VSearch
    /Library/PrivilegedHelperTools/Jack
    /System/Library/Frameworks/VSearch.framework
    ~/Library/Internet Plug-Ins/ConduitNPAPIPlugin.plugin
    Some of these items may be absent, in which case you'll get a message that the file can't be found. Skip that item and go on to the next one.
    From the Safari menu bar, select
              Safari ▹ Preferences... ▹ Extensions
    Uninstall any extensions you don't know you need, including any that have the word "Spigot" or "Conduit" in the description. If in doubt, uninstall all extensions. Do the equivalent for the Firefox and Chrome browsers, if you use either of those.
    This trojan is distributed on illegal websites that traffic in pirated movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect much worse to happen in the future.
    You may be wondering why you didn't get a warning from Gatekeeper about installing software from an unknown developer, as you should have. The reason is that the DownLite developer has a codesigning certificate issued by Apple, which causes Gatekeeper to give the installer a pass. Apple could revoke the certificate, but as of this writing, has not done so, even though it's aware of the problem. This failure of oversight is inexcusable and has compromised both Gatekeeper and the Developer ID program. You can't rely on Gatekeeper alone to protect you from harmful software.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • Is there any link between oe_order_headers_all and hz_cust_accounts tables. I need to find the cust_account_id for some order_number. Please help me with this

    Is there any link between oe_order_headers_all and hz_cust_accounts tables. I need to find the cust_account_id for some order_number. Please help me with this

    you can link
    OOH.invoice_to_org_id=CUST.cust_account_id   -- invoice customer
    OOH.sold_to_org_id=CUST.cust_account_id   -- sold to customer
    OOH.ship_to_org_id=CUST.cust_account_id   -- ship to customer

  • How can I create a new iCloud account on a preowned phone (with that persons account signed on) without deleting their whole account entirely (on all devices)? Totally confused, please help:-(

    My mum has upgraded to the iPhone 5, she has given me her 4S with a new contract etc. the problem is all her contacts are still on here and calendar dates etc . All from her iCloud account. I have my own account but I don't know how to get my phone on that without deleting her iCloud account entirely and from all devices and her new phone. Please help, I'm probably confusing things more but I really need some help

    Just delete her iCloud account from (now) your iPhone 4s - doing so will delete it from your phone and your phone only.  It will do nothing to any of her devices with her iCloud account set up on them.
    Then login in with your iCloud account login to set up your iCloud account on that iPhone 4S.
    If you want to set up the iPhone 4s with a clean slate, just delete her iCloud account, then go into general settings, under the reset tab and select "erase all content and settings".  Then run through the activation and setup dialogues with your own information.

  • Cannot erase authorization. "Unable to erase authorization. Please try after some time." Please help!!

    I am having a number of problems with Digital Editions, and I have tried the chat options numerous times but no one seems to be able to help me. I cannot express how disappointed I am with Adobe. I have an ebook that I paid a lot of money for and I need to access it for work, but when I try to download the e-book I get the error message E_ACT_NOT_READY. The forums say I need to deauthorise my account, but when I try to erase authorization I get the message "Unable to erase authorization. Please try after some time." This has been happening for weeks. For 2 weeks I have been trying to solve this problem. Can somebody please help me or give me a phone number to call to reach adobe? I am desperate at this point.

    If due to some reason, you are unable to deauthorize ADE, follow the below steps:
    Mac:
    1. Go-> Go to folder.
    Go to folder dialog will appear.
    2. Type   ~/Library/Application Support/Adobe/Digital Editions
    drag the activation.dat file to the trash.
    ADE will be deauthorized now.
    Now Authorize ADE again.
    ADE will be deauthorized now.
    Now Authorize ADE again.
    Windows:
    Choose Start > Run.
    In the Open text box, type regedit and then press Enter. The Registry Editor opens.
    In the left pane of the Registry Editor, locate the following registry key:
    HKEY_CURRENT_USER\Software\Adobe\Adept
    Right-click the Adept key and choose Delete.
    In the Confirm Key Delete dialog, click OK.
    Your authorization will be deleted.
    ADE will be deauthorized now.
    Now Authorize ADE again.

  • Internet... im so confused, please help

    I just bought my macbook and i am about to start my first year of college... i want wireless internet but have no clue how it works or what i need to buy? Do i need a modem, and if so what is it? i do not want dial up or i dont have cable to hook it up to.. please help!

    Hi
    A modem is a small unit that converts either a cable or a phone signal to something that your computer can use. When you subscribe to a high-speed internet connection, the provider (eg, Verizon, Optimum, Road Runner) includes a modem with the package. It plugs into either your cable line or your phone line, and your computer (or wired router or wireless base station) plugs into it.
    Your wireless card will only give you connection to the internet if you're in range of a wireless network. It's not like a cellphone where you can basically get service anywhere. For example, you can go to wi-fi cafes and get an internet connection (sometimes free, sometimes charged), but you usually can't stand in the middle of the street and connect to a public network (although some cities do have areas of public wifi, such as parks).
    My recommendation is to check with your college to see what they offer in terms of internet connections.
    Good luck!
    Matt

  • I am locked out of my IPod touch, i would like to retrieve the data but mainly to get back into it? i cannot however put in recovery mode for some reason? please help

    I have found my iPod touch after not using it for several years. I now cannot get into the device as i am locked out. Is there anway of getting into it without loosing the data? if not i would just like to acess it and start again. i have tried to resore the ipod and firstly put it into recovery mode. however after this process a message alert pops up saying; "the iPod could not be resored. the device cannot be found" please help? i am very frustrated with apples software to resolve the problem, is there anything else i can try?

    Sorry, there is not.
    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device
    1. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. iOS- Understanding passcodes
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. How to Recover Forgotten iPhone Restrictions Passcode | The iPhone and iPad
    6. Restoring iPod touch after forgotten passcode
    Forgotten Restrictions Passcode Help
    1. How to Recover Forgotten iPhone, iPad Restrictions Passcode
        If this method does not work, then you will need to fully Restore your
        device as New

  • My macbook pro 15" is taking lots of time to start and it shows some blueish purple screen and some graphics error please help

    I have bought macbook pro 15" i7, 4gb ram, 500 gb hdd in the month of  March year 2011. I have used it just for watching movies, surfing net and writing script on final draft software. Just two week back I started using final cut pro to edit my short film but suddenly the screen of my macbook turns black and it shuts down. After few minutes I pressed the start button but it took lots of time and open with blue-purple screen. It also get heat very soon. I don't know what the problem is. Please help.

    Boot from the install DVD and repair the startup drive
    Then run hardware test
    Using Apple Hardware Test
    Reinstall the OS
    Last
    Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar
    BTW, this is the Mac Pro desktop forum

  • Having some problems! Please help!

    Hi, I was watching a tutorial untill I got stuck in the middle of it and was hopeing if anyone could help me out. I know The tutorial is weird but I am just learning from it.
    Here is the tutorial link: http://www.youtube.com/watch?v=zrSZxOALNRY      -  got stuck at 9:22
    So I dont know how he made the picture the same size each time he placed the png in the comp area because every time I place the 2nd pic its a different size and possistioned in a different area. If anyone could please help me I would greatly apreciate it. Also please dont tell me how you hate ponys and such I am just trying to learn. If you dont get what I am saying please tell me and I will try to re phrase it.
                                                Thanks in advance! 

    Its' not obvious but he simply copied all of the transform controls for the image them into the new images.
    His workflow is not good and the tutorial is lousy. It's much more efficient and works better to apply the puppet pin to footage before you size of scale it, do the animation and then nest or pre-compose your animation in another comp to add the background layers and adjust position.  Ideally you should line up your artwork for this kind of a project before hand. A good way would be to use a layered Photoshop or Illustrator file and import the project as a composition retaining layer sizes.
    So once again, select your sized and placed image. Press the U key twice to reveal all of the changed properties, select the changed properties, then paste them to the new layers as you import them. Unfortunately, in the tutorial he only breifly mentioned copy and then never said anything about pasting it to the new layers.
    The other option would be to duplicate your sized and placed layer as many times as necessary, then replace that layer with a new one from the project panel by selecting the layer in the timeline, then selecting the new footage in the project panel, then holding down the Alt/Option key and dragging from the Project Panel to the Timeline.

  • I have updated my iPhone and I was able to text my friend but now that I have updated my iPhone it shows that it's an iMessage and it won't go through, I know I'm supposed to turn on my Internet but I'm confused please help?

    I was able to text my friend to her number but now that I have updated my iPhone it shows that it's an iMessage when I text her to the same number, I know that with iMessages you have to turn on your Internet but I'm texting her to her same number so it shouldn't be an iMessage. Can someone please help?

    Hi rennekamp3,
    If your machine currentlty won't boot past a grey Apple screen, you may find the following article helpful:
    Mac OS X: Gray screen appears during startup
    http://support.apple.com/kb/ts2570
    Note: If you get to the portion on starting from the Install Disks or performing an Archive/Erase & Install, you'll notice this article has not yet been updated for the more recent operating systems. In that case, you may want to refer to the following article:
    OS X: About OS X Recovery
    http://support.apple.com/kb/ht4718
    Regards,
    - Brenden

Maybe you are looking for

  • Using home sharing between pc and iphone

    I have enable home sharing and the option does not show up on the right side of itunes. how can i get this to show and also transfer music from my pc to my iphone wirelessly.  Thanks.

  • 12 hours to render? is that normal?

    I have a G5 dual 2.7GHZ machine with 8GB of RAM. 250GB internal drive with 140GB available space, 500GB external Lacie drive with 300GB available space. and I keep all my project files on the external drive when I work on any project. So, I recently

  • Macbook pro retina, windows 7, how to install it without using optical drive?

    Hi, I am thinking of buying the new macbook pro with retina display. I do not intend to get and external optical drive. I want to split the hard disk and install a windows 7 ultimate, which I own and have as an CD image ( ISO file ). how can I instal

  • Withholding Taxes not calculating

    Hi All, Currently we are using ECC 6.0. While creating Vendor we are assigning With Holding Tax codes and I created a BP with this Vendor. Now I created a Lease-In Contract for this BP, but system asking tax types and tax group is mandetory under Pos

  • Problem in mail trigger

    Hi experts,                    We are facing an issue in worklfow for notification.We need to assign a person responsible in QM02 and it triggers a mail whom so ever assigned as a person responsible.Its working fine in sanbox,dev and quality.But for