I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
A QUESTION FROM KATHY SIERRA SCJP BOOK
Please explain this question to me. I am unable to understand the casting concepts...
OCPJP 6-100%; Preparing for GATE11
OCPJP 6-100%; Preparing for GATE11
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
OCPJP 6-100%; Preparing for GATE11
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
SCJP6.0,My blog Ranchers from Delhi
Jan Osykowski wrote:
Also would like to ask a question about scoping and shadowing.
There is an error that a identifiers are duplicated. But they are in different scopes, aren't they? So the shadowing should come in play, no?
Cheers,
Jan.
If a declaration of an identifier as a local variable of the same method, constructor, or initializer block appears within the scope of a parameter or local variable of the same name, a compile-time error occurs.
Thus the following example does not compile:
class Test {
public static void main(String[] args) {
int i;
for (int i = 0; i < 10; i++)
System.out.println(i);
}
}
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Regards,
Avishkar Nikale
I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Mark Uppeteer wrote:huh?
there's no method with parameters,...its a for loop.
Regards,
Avishkar Nikale
Jan Osykowski wrote:
Long is 64 bits and float is 32 bits. So I think the explicit cast should be needed but this code compiles. Can anyone explain?
Cheers,
Jan.
Regards,
Avishkar Nikale
Avishkar Nikale wrote:
Jan Osykowski wrote:
Long is 64 bits and float is 32 bits. So I think the explicit cast should be needed but this code compiles. Can anyone explain?
Cheers,
Jan.
Jan,
If you see the actual range of numbers then a long can easily fit into a float.
This would have been applicable if the code used double where a 64 to 32 bit truncation was necessary.
Cheers,
Divyesh.
Divyeshh Patel wrote:
Avishkar,
Considering the float and long range, I think long cannot fit into float range without loss of precision.
Regards,
Avishkar Nikale
I love a good mentalist. And so does this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|