What Will Be The Output Of The Following Java Codep Pre #475
What will be the output of the following Java code?</p> <pre><code class="language-java"> import java.io.*; class TransientAndFinal implements Serializable { int num1 = 50; transient final int num2 = 100; public static void main(String[] args) throws Exception { TransientAndFinal t = new TransientAndFinal(); 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); TransientAndFinal t1 = (TransientAndFinal) 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.