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
Comments
Leave a comment