Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


can write code for serialization ?



can write code for serialization ?..

Answer / bharat shivram

import java.io.*;
public class SerializationDemo {
public static void main(String args[]) {
// Object serialization
try {
MyClass object1 = new MyClass("Hello", -7, 2.7e10);
System.out.println("object1: " + object1);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object1);
oos.flush();
oos.close();
}
catch(Exception e) {
System.out.println("Exception during serialization: " + e);
System.exit(0);
}

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Core Java Interview Questions

There can be a abstract class without abstract methods, but what is the need to declare a class abstract if it doesn't contain abstract methods?

5 Answers   HCL,


Are static members inherited to sub classes?

0 Answers  


What does escaping a character mean?

0 Answers  


What is temp in java?

0 Answers  


What is scope & storage allocation of global and extern variables? Explain with an example

0 Answers   IBS,


why static class in java or what is use of static class in java

3 Answers   SunGard,


I want to re-reach and use an object once it has been garbage collected. How it's possible?

0 Answers  


Explain the init method?

0 Answers  


What are unchecked exceptions in java?

0 Answers  


Can we have 2 main methods in java class?

0 Answers  


Which package is imported by default?

0 Answers  


What are the fileinputstream and fileoutputstream?

0 Answers  


Categories