Computer Science · Java Programming
What is the output of the following Java code segment? String[] s = new String[3]; s[0] = new String('zero'); s[1] = new String('one'); s[2] = new String('two'); s[1] = s[2]; s[0] = s[1]; s[2] = s[0]; for(int i = 0; i < s.length; i++) { System.out.print(s[i] + ' '); }
- 1zero one two
- 2one two zero
- 3two two two✓
- 4two one zero
Correct answer
two two two
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Java Programming?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Java Programming