Ramaseshan T<br />SCJP 1.4
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Ramaseshan T<br />SCJP 1.4
Ramaseshan T<br />SCJP 1.4
Can we conclude that polymorphic behaviour is present and exhibited only on Methods and not on variables?
Tony Morris
Java Q&A (FAQ, Trivia)
what is the difference b/w non-constant and non-final
15.28 Constant Expression
ConstantExpression:
Expression
A compile-time constant expression is an expression denoting a value of primitive type or a String that is composed using only the following:
* Literals of primitive type and literals of type String
* Casts to primitive types and casts to type String
* The unary operators +, -, ~, and ! (but not ++ or --)
* The multiplicative operators *, /, and %
* The additive operators + and -
* The shift operators <<, >>, and >>>
* The relational operators <, <=, >, and >= (but not instanceof)
* The equality operators == and !=
* The bitwise and logical operators &, ^, and |
* The conditional-and operator && and the conditional-or operator ||
* The ternary conditional operator ? :
* Simple names that refer to final variables whose initializers are constant expressions
* Qualified names of the form TypeName . Identifier that refer to final variables whose initializers are constant expressions
Compile-time constant expressions are used in case labels in switch statements (�14.10) and have a special significance for assignment conversion (�5.2).
A compile-time constant expression is always treated as FP-strict (�15.4), even if it occurs in a context where a non-constant expression would not be considered to be FP-strict.
Examples of constant expressions:
true
(short)(1*2*3*4*5*6)
Integer.MAX_VALUE / 2
2.0 * Math.PI
"The integer " + Long.MAX_VALUE + " is mighty big."
Mike Gershman
SCJP 1.4, SCWCD in process
Originally posted by ramaseshan T:
Expected Output:2,Sub (As Sup holds a subclass object)
Actual Output: 5, Sub
Can you please explain?
Javainn<br /> <br />SCJP,SCWCD,SCBCD,<br />ICED (IBM-287,IBM-484,IBM-486)
IBM certified in DB2 V 8.1 Family Fundamentals (IBM 700)
what is the difference b/w non-constant and non-final
I nebver read the whole post , just read your post , so IMO in java final means constants ( for variable ) so non-constants & non-final should be same ...
Tony Morris
Java Q&A (FAQ, Trivia)
A class or interface type T will be initialized immediately before the first occurrence of any one of the following:
T is a class and an instance of T is created.
T is a class and a static method declared by T is invoked.
A static field declared by T is assigned.
A static field declared by T is used and the reference to the field is not a compile-time constant (�15.28). References to compile-time constants must be resolved at compile time to a copy of the compile-time constant value, so uses of such a field never cause initialization.
Don't get me started about those stupid light bulbs. |