Oracle OCA J2SE7 Cetificate - Rules for Primitive Types

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle OCA J2SE7 Cetificate - Rules for Primitive Types相关的知识,希望对你有一定的参考价值。

  • Any bigger than an int can NEVER be assigned to an int or anything smaller than int (byte, char, or short) without explicit cast.


  • Constant values up to int can be assigned (without cast) to variables of lesser size (e.g. short to byte) if the values are representable by the variable.


  • Operands of mathematical operators are ALWAYS promoted to AT LEAST int. (e.g. byte*byte both bytes will be first promoted to int) and the return value will be AT LEAST int.


  • Compound assignment operators (+=, *= etc) have strange ways so ready this carefully: A compound assignment expression of the form E1 op = E2 is equivalent to E1 = (T)((E1) op (E2)), where T is the type of E1


  • A char value can ALWAYS be assigned to an int variable, since the int type is wider than the char type.


  • A narrowing primitive conversion may be used if all of the following conditions are satisfied:

    1. The expression is a constant expression of type int.

    2. The type of the variable is byte, short or char.

    3. The value of expression is representable in the type of the variable.

    4. NOTE THAT narrowing conversion doesn‘t apply to long or double. So, char ch = 30L; will fail althrough 30 is representable by a char.


以上是关于Oracle OCA J2SE7 Cetificate - Rules for Primitive Types的主要内容,如果未能解决你的问题,请参考以下文章

OCA java8 (1Z0-808)考试经验分享

什么是ORACLE OCP?

关于 Java 8(OCA)中的短路运算符和后缀增量的问题 [关闭]

ORACLE 考证有多难?

OCA U详细订单管理电子邮件通知(1.5.2)vQmod-仅适用于1.5.6.4 OpenCart v1.5.x

OCA U详细订单管理电子邮件通知(1.5.2)vQmod-仅适用于1.5.6.4 OpenCart v1.5.x-