1z0-829 Exam QuestionsBrowse all questions from this exam

1z0-829 Exam - Question 42


Given the code fragments:

and:

Which action prints Wagon : 200?

Show Answer
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

3 comments
Sign in to comment
TojoseOption: E
Jan 11, 2024

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

SampsOption: E
Apr 21, 2024

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

xplorerpjOption: E
Jun 25, 2024

E is correct answer