What is the output for the below code running in the same JVM? public class A implements Serializable { transient int a = 7; static int b = 9; } public class B implements Serializable { public static void main(String... args){ A a = new A(); try { ObjectOutputStream os = new ObjectOutputStream( new FileOutputStream("test.ser")); os.writeObject(a); os. close(); System.out.print( + + a.b + " "); ObjectInputStream is = new ObjectInputStream(new FileInputStream("test.ser")); A s2 = (A)is.readObject(); is.close(); System.out.println(s2.a + " " + s2.b); } catch (Exception x) { x.printStackTrace(); } } }
Reveal answer
Fill a bubble to check yourself
Keep practicing — related questions
- What is the output for the below code ? public class A {} public class B implements Serializable { A a = ne...
- What is the output for the below code ? public class A { public A() { System.out.println("A"); } } public c...
- What is the output for the below code ? public class A { public A() { System.out.println("A"); } } public c...
- What is the output? public class Wow { public static void go(short n) {System.out.println("short");} public...
- What is the output for the below code ? class A { { System.out.print("b1 "); } public A() { System.out.prin...
- What will be the output of the program? public abstract class AbstractTest { public int getNum() { return 4...
- What is the output for the below code ? class A implements Runnable{ public void run(){ System.out.println(...
- What is the output for the below code ? class A implements Runnable{ public void run(){ System.out.println(...