Given the code fragments:
and:Which action prints Wagon : 200?
Given the code fragments:
and:Which action prints Wagon : 200?
To print 'Wagon : 200', the object must be deserialized correctly. In the given code, 'ois.readObject()' needs to return a LuxuryCar object for the toString() method to be called correctly and to print the desired output. By replacing 'Car' with 'LuxuryCar' at line n3, it ensures that the returned object is treated as an instance of LuxuryCar, thus calling the correct toString() method, resulting in 'Wagon : 200' being printed.
the right option is E. At line n2, in the main method signature, add throws IOException, ClassNotFoundException.
the right option is E. At line n2, in the main method signature, add throws IOException, ClassNotFoundException.
E is correct answer