OTHER ANSWERS ON CHEGG ARE INCORRECT SELECTIONS ARENT NECESSARILY CORRECT 5. Ass
ID: 3916453 • Letter: O
Question
OTHER ANSWERS ON CHEGG ARE INCORRECTSELECTIONS ARENT NECESSARILY CORRECT 5. Assume that you have an aray of integers named a Which of these code segments print the same results? (2 points) t.int?. 0; System.out prinnat for 0 " 0; a.length; i++) for Onea) System.out prind 1 and 11l onl All three print the same esuts ABthree grnt different results. Suppose that you have Arrayus' and the" ertans String objects. whith declaraton ee 1. ArrayList.. ne" ArrayLiet?? Arrenat does not require that objects retneved a??? neod be cast to S nrgs telere categ . Stmg method? (2 pu 11AresytateStrings array List () ne 1 only It only 111 orly 1, 11, and onl , wech of the llowing ines of code could st be ssed to sore a random number between 1 and 6,indusive, into the variable diee? (2 poins L. int diceMath random(6); IL. int dice Hath.random6) I1 only 111 only 1, 11, and1 1 and only
Explanation / Answer
Answer 1:
All three print the same result.
but we are using different loops to print like for loop, while loop and for each loop.
Answer 2:
III only.
ArrayList<String> a = new ArrayList<String>()
it is generic type and we mentioned type as string and no need to cast while getting.
Answer 3:
III only
int dice=(int)(Math.random()*6)+1;
math.random() will return double. so we need to typecast into int.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.