What Will Be The Output Of The Following Java Codep Pre #467
What will be the output of the following Java code?</p> <pre><code class="language-java"> import java.io.*; class TransientVariables implements Serializable { int num1 = 20; transient int num2 = 30; public static void main(String[] args) throws Exception { TransientVariables t = new TransientVariables(); FileOutputStream fo = new FileOutputStream("input.txt"); ObjectOutputStream oo = new ObjectOutputStream(fo); oo.writeObject(t); FileInputStream fi = new FileInputStream("input.txt"); ObjectInputStream oi = new ObjectInputStream(fi); TransientVariables t1 = (TransientVariables) oi.readObject(); System.out.println("num1: " + t1.num1); System.out.println("num2: " + t1.num2); } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 Class Components (Using Java) - Data Members - Quiz No.1.