Exam 1z0-829 All QuestionsBrowse all questions from this exam
Question 42

Given the code fragments:

and:

Which action prints Wagon : 200?

    Correct Answer: B

    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.

Discussion
TojoseOption: E

the right option is E. At line n2, in the main method signature, add throws IOException, ClassNotFoundException.

SampsOption: E

the right option is E. At line n2, in the main method signature, add throws IOException, ClassNotFoundException.

xplorerpjOption: E

E is correct answer