77 919
Assignments Done
Successfully Done
In August 2019

Answer to Question #20459 in Java | JSP | JSF for nohra

Question #20459
26. Since the readObject method returns a generic object, what must we do with the returned object?
Expert's answer
You need to do an Object typecasting
Syntax: (classname) generic object
The following example casts an instance of the classVicePresident to an instance of the classEmployee; VicePresident is a subclass
of Employee with more information, which here defines that the VicePresident
has executive washroom privileges:
Employee emp = new Employee();
VicePresident veep = new VicePresident();
emp = veep; // no cast needed for upward use
veep = (VicePresident)emp; // must cast explicitly

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions