• [SCJP](四)语言基础

    分类: | 2006年08月13日

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://www.blogbus.com/xydonkey-logs/3040218.html

    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
    double

    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;
       System.out.println(b);
    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 ____.
    int
    除了long,其它的整数型(byte,char,short)都被转换成int。

    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.
    True
    向上转型是自动的,向下转型需要显示说明。

    分享到:
    Tag:Java
    引用地址: