Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5 Question 21 What is the output? int x = 18; while (x > 0) { } // Output x and a space x
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 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 @ / 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started