• [SCJP](四)语言基础

    分类: | 2006年08月13日


    1. An interface type can be converted to any other interface type.
    False, for an interface to be converted to another , the new one should be a super interface of the old one.

    2. A 'char' type can be assigned to a double variable (without casting).
    Yes, a 'char' type can be assigned to a double without casting because double is large enough to hold any integral type (char is stored as an integer).

    3. A boolean may be converted to integer and vice-versa by casting.
    False, a boolean cannot be converted to any other type.

    4. In an expression, which has 2 operands, one of which is a long and the other is a float the result will be of ___ type

    5. Implicitly converting an interface type to a class type is never allowed.
    An interface type can be converted to a class type, only if the class implements the interface.

    6. byte b = (byte)256;
    Value of b printed is ___.
    Zero. Since since the integer's value is larger than the byte's range (-128-+127), the result is the remainder of the division of the integer value by the byte's range (256).

    7. For unary operators, if the operand is a byte, char or a short, it is coverted to ____.

    8. An array can be converted to an object of the class Object without casting.
    All arrays are objects. So they can be assigned to any object of class Object.

    9. An array of integers can be converted to an array of bytes by casting.
    False, only an array of object references can be assigned to another array.

    10. A subclass object can be assigned to a super class type without casting.