26. Since the readObject method returns a generic object, what must we do with the returned object?
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!
Learn more about our help with Assignments:
JavaJSPJSF