in Education by
Which is better in terms of performance for iterating an array? (a) for(int i=0; i<100; i++) (b) for(int i=99; i>=0; i–) (c) for(int i=100; i<0; i++) (d) for(int i=99; i>0; i++) I had been asked this question in a job interview. Origin of the question is Coding best practices topic in section Autoboxing & Miscellaneous of Java Select the correct answer from above options JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Correct option is (b) for(int i=99; i>=0; i–) The best I can explain: reverse traversal of array take half number cycles as compared to forward traversal. The other for loops will go in infinite loop.

Related questions

0 votes
    When is an application said to show a web performance? (a) Time to respond (b) Time to load (c) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which of these method of Array class is used sort an array or its subset? (a) binarysort() (b) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Why is the replace() method better than the assign() method? (a) Reliable (b) Highly manageable ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which of the following shows a poorer runtime performance for coalescing functionality, using functions, and using ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
0 votes
    How many properties are there in window.performance object? (a) 1 (b) 4 (c) 2 (d) 3 The ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    How can we define the term Performance? (a) Speed of the input takes in (b) Speed of the output ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    What does the method Performance.now() return? (a) DOMTimeStamp (b) DOMHighResTimeStamp (c) DOM\Stamp (d ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
0 votes
    The pop() method of the array does which of the following task? (a) decrements the total length ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    The primary purpose of the array map() function is that it __________ (a) maps the elements of another ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
...