Gen an object of Random Class that is Random gen new Random
Gen an object of Random Class that is Random gen - new Random(). If we want to use gen and, its method nextInt to generate integers in the following ranges, which kind of sentences we should write What output is produced by the following? String sir - \"Space, a Final Frontier\"; System, out.printIn(str. length()); System out.println(str.substring(7)); System out println(str toLowerCase()); System. oul.println(str. length!)); How many times will the string \"Hello World\" be printed? And explain the reasons count I = 10; while (count I >0) {count2 = 15; while (count2 > = 10) {System. out.println(\"Here\"); count2-:} countI:}
Solution
Answer:
2.8
The outer loop will run for 10 times (since count1 > 0 is the condition and initial value of count1 = 10) and inner loop will run 6 times(count2 value is allowed till 10 and initial value = 15 at the beginning of each outer loop) .So total no of times it gets printed = 10 * 6 = 60
