1: public class Squares { 2: public static long square(int x) { 3: long y = x * (long) x; 4: x = -1; 5: return y; 6: } 7: public static void main(String[] args) { 8: int value = 9; 9: long result = square(value); 10: System.out.println(value); 11: } }
❌ A. -1 ✅ B. 9 ❌ C. 81 ❌ D. Compiler error on line 9. ❌ E. Compiler error on a different line
Explanation: Since Java is pass-by-value and the variable on line 8 never gets reassigned, it stays as 9. In the method square, x starts as 9. y becomes 81 and then x gets set to –1. Line 9 does set result to 81. However, we are printing out value and that is still 9.
1: public class Squares { 2: public static long square(int x) { 3: long y = x * (long) x; 4: x = -1; 5: return y; 6: } 7: public static void main(String[] args) { 8: int value = 9; 9: long result = square(value); 10: System.out.println(value); 11: } }
❌ A. -1 ✅ B. 9 ❌ C. 81 ❌ D. Compiler error on line 9. ❌ E. Compiler error on a different line
Explanation: Since Java is pass-by-value and the variable on line 8 never gets reassigned, it stays as 9. In the method square, x starts as 9. y becomes 81 and then x gets set to –1. Line 9 does set result to 81. However, we are printing out value and that is still 9.
BY Explanations “Top Java Quiz Questions”
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Telegram is a cloud-based instant messaging service that has been making rounds as a popular option for those who wish to keep their messages secure. Telegram boasts a collection of different features, but it’s best known for its ability to secure messages and media by encrypting them during transit; this prevents third-parties from snooping on messages easily. Let’s take a look at what Telegram can do and why you might want to use it.
In many cases, the content resembled that of the marketplaces found on the dark web, a group of hidden websites that are popular among hackers and accessed using specific anonymising software.“We have recently been witnessing a 100 per cent-plus rise in Telegram usage by cybercriminals,” said Tal Samra, cyber threat analyst at Cyberint.The rise in nefarious activity comes as users flocked to the encrypted chat app earlier this year after changes to the privacy policy of Facebook-owned rival WhatsApp prompted many to seek out alternatives.telegram from in