Загрузка...

Day-143: Can you solve this do-while #daily #java #coding #quiz #shorts

Welcome to daily coding challenge!!!

The correct answer to the code shown in video is:
E. Compilation error

Explanation:
E. In this code, the variable snake is declared inside the do block, meaning its scope is limited to that block only.
When the while (snake less than equal 5) condition is evaluated, snake is no longer in scope, causing a compilation error.
Java does not allow access to variables declared in a block once that block ends.
If snake had been declared outside the loop (e.g., before the do statement), the loop would have executed multiple times, printing incremented values and decrementing iguana each time.
But due to the scoping issue, the correct answer is E.

The code, options and answer is verified in Eclipse IDE with Java 21. Incase you find it wrong then feel free to DM me over LinkedIn/Instagram. Just ensure you share screenshot of question and answer which you are getting in your IDE.

Subscribe the channel for regular Java updates.
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Social Media Handles:
• Website: https://abhishekvermaa10.github.io
• YouTube: https://www.youtube.com/@abhishekvermaa10
• Instagram: https://www.instagram.com/abhishekvermaa10
• LinkedIn: https://www.linkedin.com/in/abhishekvermaa10
• GitHub: https://github.com/abhishekvermaa10
• TopMate: https://topmate.io/abhishekvermaa10
• X: https://x.com/ytabhishekverma
• Telegram: https://t.me/ScaleUpIndiayt
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Copyright © 2025 Abhishek Verma - All Rights Reserved

Видео Day-143: Can you solve this do-while #daily #java #coding #quiz #shorts канала Abhishek Verma
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять