5 Question 21 What is the output? int x = 18; while (x > 0) {...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
5 Question 21 What is the output? int x = 18; while (x > 0) { } // Output x and a space x = x / 3; 62 18 62 620 O 186 20 2 pts Question 22 What is the output if count is 4? for (i = count; i > 0; --i) { // Output i } 4321 4 43210 321 2 pts Question 23 What is the ending value of sum, if the input is 2 5 7 3? All variables are integers. x = scnr.nextInt (); sum = 0; for (i = 0; i < x; ++i) { } () currValue = scnr.nextInt (); sum += currValue; 10 15 12 50 2 pts Question 24 What is the output? 0 for (i = 0; i <= 10; ++i) { if (i == 6) continue; else } System.out.print(i + "); O 012345 0123457 8 9 10 012345789 0123456 2 pts Question 25 For the given pseudocode, which XXX and YYY will output the smallest non-negative input (stopping when a negative value is input)? Choices are in the form XXX/YYY. 0 min = 0 val min = val While val is not negative If XXX YYY val Get next input Put min to output O O ) Get next input ) ) min <val / val = min val > @ / min = val val< min / min = val 2 pts val > min / val = min Question 26 Which is the best capacity for an oversize array that records daily phone sales during a month. Maximum number of sales for a single day is 100. 31 30 100 99 2 pts > Question 27 What is the output when calling printName("Juan", 19); public static void printName(String name, int id) { System.out.print(name + " ID: " + id); } public static void printName(int id) { System.out.print("Name" + " ID: " + id); } public static void printName (String name, int id, System.out.print(name + " ID: " + id + " age: } Juan ID: 19 age: 19 There is no output Juan ID: 19 Name ID: 19 int age) { + age); 2 pts Question 28 How does using findMax() improve the code? public static int findMax(int vall, int val2) { int max; if(val1 > val2) { max = vall; } else{ max = val2; } return max; } public static void main(String args[]) { int maxl; int max2; int max3; max1 = findMax (15, 7); max2 = findMax (100, 101); max3 = findMax (20, 30); Using findMax() does not improve the code Using findMax() reduces the number of variables Using findMax() decreases redundant code O Using findMax() makes main() run faster 2 pts > Question 29 Which statement is true? void swap(int age, int [] grades) { the value of grades [2] is stored in the heap the value of age is stored in the heap the reference to grades is stored in the heap the elements in grades can not be modified within the method 2 pts Question 30 What is output? 0 public static void changeRainfall (double [] dailyRain) { dailyRain [0] = 0.1; } public static void main(String args[]) { double [] rainValues = new double [2]; } O rainValues [0] = 2.9; rainValues [1] = 1.3; changeRainfall (rainValues); System.out.println(rainValues[0]); 2.9 0.1 an array reference 1.3 2 pts 5 Question 21 What is the output? int x = 18; while (x > 0) { } // Output x and a space x = x / 3; 62 18 62 620 O 186 20 2 pts Question 22 What is the output if count is 4? for (i = count; i > 0; --i) { // Output i } 4321 4 43210 321 2 pts Question 23 What is the ending value of sum, if the input is 2 5 7 3? All variables are integers. x = scnr.nextInt (); sum = 0; for (i = 0; i < x; ++i) { } () currValue = scnr.nextInt (); sum += currValue; 10 15 12 50 2 pts Question 24 What is the output? 0 for (i = 0; i <= 10; ++i) { if (i == 6) continue; else } System.out.print(i + "); O 012345 0123457 8 9 10 012345789 0123456 2 pts Question 25 For the given pseudocode, which XXX and YYY will output the smallest non-negative input (stopping when a negative value is input)? Choices are in the form XXX/YYY. 0 min = 0 val min = val While val is not negative If XXX YYY val Get next input Put min to output O O ) Get next input ) ) min <val / val = min val > @ / min = val val< min / min = val 2 pts val > min / val = min Question 26 Which is the best capacity for an oversize array that records daily phone sales during a month. Maximum number of sales for a single day is 100. 31 30 100 99 2 pts > Question 27 What is the output when calling printName("Juan", 19); public static void printName(String name, int id) { System.out.print(name + " ID: " + id); } public static void printName(int id) { System.out.print("Name" + " ID: " + id); } public static void printName (String name, int id, System.out.print(name + " ID: " + id + " age: } Juan ID: 19 age: 19 There is no output Juan ID: 19 Name ID: 19 int age) { + age); 2 pts Question 28 How does using findMax() improve the code? public static int findMax(int vall, int val2) { int max; if(val1 > val2) { max = vall; } else{ max = val2; } return max; } public static void main(String args[]) { int maxl; int max2; int max3; max1 = findMax (15, 7); max2 = findMax (100, 101); max3 = findMax (20, 30); Using findMax() does not improve the code Using findMax() reduces the number of variables Using findMax() decreases redundant code O Using findMax() makes main() run faster 2 pts > Question 29 Which statement is true? void swap(int age, int [] grades) { the value of grades [2] is stored in the heap the value of age is stored in the heap the reference to grades is stored in the heap the elements in grades can not be modified within the method 2 pts Question 30 What is output? 0 public static void changeRainfall (double [] dailyRain) { dailyRain [0] = 0.1; } public static void main(String args[]) { double [] rainValues = new double [2]; } O rainValues [0] = 2.9; rainValues [1] = 1.3; changeRainfall (rainValues); System.out.println(rainValues[0]); 2.9 0.1 an array reference 1.3 2 pts
Expert Answer:
Answer rating: 100% (QA)
Solutions The correct output is 18 6 2 The program in C language can be coded as below we only need to change the commented line with cout statement include using namespace std int main int x 18 while... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
What are the corporate governance issues being experienced at Twitter pre and post musk and what type of theory is being practiced at Twitter is it agency theory, stakeholder theory etc?
-
Hansel Electronics has the following: If Hansel has 7,000 units on hand at December 31, the cost of ending inventory under the average-cost method is: (a) $84,000. (b) $70,000. (c) $56,000. (d)...
-
How well does IKEA's strategy translate in other cultures outside of Western Europe? What are some advantages to maintaining a consistent global strategy? What are some disadvantages?
-
What is the endosymbiotic hypothesis for the origin of mitochondria and chloroplasts? What evidence supports this hypothesis?
-
What is the daughter nucleus of the decay? The Curiosity rover sent to explore the surface of Mars has an electric generator powered by heat from the radioactive decay of \({ }^{238} \mathrm{Pu}\), a...
-
TPo1 Company borrowed $300,000 on January 1, 2010, by issuing a $300,000, 8% mortgage note payable. The terms call for semiannual installment payments of $20,000 on June 30 and December 31....
-
(a) I need help from someone with experience in 802.11 wireless standards. (b) I need help in you own words explaining the following assignment please. (c) Research the 802.11 Wireless Standards,...
-
(a) Prepare income statements for January and February for Fazli, Gervais, and Consolidation. Break down cost of sales into its three components. (b) Now assume that Fazli uses the equity method to...
-
find an example problem that can be solved using Machine Learning. In this regards, show how does Machine Learning approach solve that problem. Please thoroughly describes ?!
-
Let A be the matrix 1 1 1 -2 0-3 4 0 6.5 (a) Let = [100], = [010] and d = [001]. Use Gauss-Jordan elimination, solve the three equations Ax = 6, Ay = and Az = d to find x, y and z. (b) Hence, or...
-
Briefly explain the meaning of moral hazard, and identify two ways in which an insurer can design a policy covering theft to reduce the risk of moral hazard
-
2] Merrick goes to the farmer's market to buy exotic fruit. Last week, he bought 15 rambutan at 20 cents each. This week, rambutan prices increased to 30 cents each, and Merrick buys only 10 rambutan...
-
Differentiate. F(x) = (3x+7) F'(x) =
-
What is the economic principle that guides efforts to analyze the costs of inflation and deflation?
-
List the following compounds in order of decreasing boiling point: a. CH3CH2CH,CH,CH2CH,Br CH;CH,CH,CH,Br CH;CH,CH,CH,CH,Br CH3 CH3 b. CH,CHCH,CH,CH,CH,CH3 CH;C - CCH3 H3 H; CH3...
-
What are the two methods used to translate financial statements and how does the functional currency play a role in determining which method is used?
-
a. What is the relative frequency of an event? b. How is the relative frequency different from the probability of an event? c. What is the law of large numbers?
-
You are supervising an audit to decide whether or not any errors in the recording of account transactions are material errors. Each account has a reported balance, whose accuracy can be verified only...
-
Some of your advertisements seem to get no reaction, as though they are being ignored by the public. You have arranged for a study to measure the publics awareness of your brand before and after...
-
What is the current in the wire in Figure Q22.1? 1.0 VR + 1.0-1.0V + FIGURE Q22.1
-
Electroconvulsive therapy is a last-line treatment for certain mental disorders. In this treatment, an electric current is passed directly through the brain, inducing seizures. The total charge that...
-
A laptop battery has an emf of 10.8 V. The laptop uses 0.70 A while running. a. How much charge moves through the battery each second? b. By how much does the electric potential energy of this charge...
Study smarter with the SolutionInn App