Telegram Group & Telegram Channel
What is the result of the program?

A. num1 == num2 and num3 == num4
B. num1 == num2 and num3 != num4
C. num1 != num2 and num3 == num4
D. num1 != num2 and num3 != num4
E. The code does not compile
F. A runtime exception is thrown

Explanation:
We always thought that whenever two object references are compared using “==”, it always evaluates to “false”. But here Integer caching changes the results. Integer class has a caching range of -128 to 127. Whenever a number is between this range and autoboxing is used, it assigns the same reference. That’s why for value 100, both num1 and num2 will have the same reference, but for the value 500 (not in the range of -128 to 127), num3 and num4 will have different reference.



tg-me.com/topJavaQuizExplain/126
Create:
Last Update:

What is the result of the program?

A. num1 == num2 and num3 == num4
B. num1 == num2 and num3 != num4
C. num1 != num2 and num3 == num4
D. num1 != num2 and num3 != num4
E. The code does not compile
F. A runtime exception is thrown

Explanation:
We always thought that whenever two object references are compared using “==”, it always evaluates to “false”. But here Integer caching changes the results. Integer class has a caching range of -128 to 127. Whenever a number is between this range and autoboxing is used, it assigns the same reference. That’s why for value 100, both num1 and num2 will have the same reference, but for the value 500 (not in the range of -128 to 127), num3 and num4 will have different reference.

BY Explanations “Top Java Quiz Questions”


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/topJavaQuizExplain/126

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

The Singapore stock market has alternated between positive and negative finishes through the last five trading days since the end of the two-day winning streak in which it had added more than a dozen points or 0.4 percent. The Straits Times Index now sits just above the 3,060-point plateau and it's likely to see a narrow trading range on Monday.

telegram from kr


Telegram Explanations “Top Java Quiz Questions”
FROM USA