Object t = new Integer(107);
int k = (Integer) t.intValue()/9;
System.out.println(k);
One (ok,atleast Iam the one) thinks that the question might be from Wrapper classes.so the obj reference with Integer runtime Object can be converted to wrapper type and invoking intValue is Legal.
But,actually the question
test Operators Objective.Compiler will complain that the method intValue() is not available in Object.
"." Operator Executes first than the
Cast Operator causing compiler Error.This is because the
. operator has more precedence than the
cast operator,so have to write it
int k = ((Integer) t).intValue()/9;
Whizlabs,JQPlus Test Interfaces provides Review Button which gives Objective of a Question.If we know the Objective,We can dodge Questions like these.What about the Real Exam,is it with same Testing Interface like Whizlabs and Enthuware? [ January 06, 2007: Message edited by: ramya sri ]