Home » JAVA Programming » Java Basic » Question
  1. Which is better in terms of performance for iterating an array?
    1. for(int k=50; k>=0; k–)
    2. for(int k=0; k<50; k++)
    3. for(int k=50; k>0; k++)
    4. for(int k=50; k<0; k++)
    5. None of these
Correct Option: A

reverse traversal of array take half number cycles as compared to forward traversal. The other for loops will go in infinite loop.



Your comments will be displayed only after manual approval.