Paul Anilprem wrote:This is because the type of the conditional operator when operands 2 and 2 are objects is Object. Specification defines it clearly in Section 15.25, Table 15.25-E. The compiler, therefore, has no choice but to accept the assignment.
Lilou Laure wrote:I want to know why does line 14 even compile ? But it throws an exception. But why should it compile ! In the below code, String and char are incompatible it says so cannot be cast. But in the above code, a similar situation is seen, where, String type and Integer type is being attempted to be cast to a char . isn't that wrong then ?
Lilou Laure wrote:and should this table be learnt for the exam ?