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?
1
Expert's answer
2012-12-11T09:30:04-0500
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS