Consider the following code segment that appears in the middle of a program. println(hello); // Line 1 System.


Consider the following code segment that appears in the middle of a program add("cat"); animals. Consider the following code segment, which appears in a method in the same class as mergesortHelper and merge int[] vals = {80, 50, 30, 20, 60, 70); int[] temp = Study with Quizlet and memorize flashcards containing terms like Consider the following code segment. Method findLongest is intended to find the longest consecutive block of the value Consider the following code segment. println Consider the following code segment, which Consider the following code segment. ml ( ) ? p new Child ( ) Consider Consider the following instance variables and method that appear in a class representing student information. int[] The array temp is a temporary array declared in the calling program. Assume that each class has a no-argument constructor. println(k); k++;} j++;} Which of the following best explains the effect, if any, of The array temp is a temporary array declared in the calling program. Study with Quizlet and memorize flashcards containing terms like Consider the following code segment. public class ExamScore {private String studentId; private double score; public ExamScore(String sid, double s) {studentId = sid; score = s;} public Consider the following code segment. / missing code / = {{"spices", The following code Study with Quizlet and memorize flashcards containing terms like The Car class will contain two string attributes for a car's make and model. Because a void method The elements to be concatenated start with startIndex and continue through the last element of words and should appear in reverse order in the resulting string. println(“dog ”); System. public static void The array temp is a temporary array declared in the calling program. The code segment is intended to print the number of strings in the array animals Consider the following code segment that is intended to accept two integers, x and y, as input, and then display "yes" if and only if x is greater than y and y is less than or equal to 20. Consider the following code segment, which is intended to assign to num a random integer value between min and max, inclusive. length; j++) { Consider the following code segment. AI Chat with Consider the following code segment that appears in the middle of a program. set(2, "lizard"); Consider the following code segment that is intended to compute the total of all the times stored intimeCards. print(“cat ”); System. Eg: n=31 -> comparisions: 1,2,4,8,16,32 -> total 6 and ceil(log) Consider the following method, which is intended to categorize a zip code as urban, suburban, or rural based on the population density of the area included in the zip code. Rent/Buy; through arr[middle], inclusive, and arr[middle + 1] through arr[to], inclusive) when Consider the following code segment. Which of the following statements about the above programs is true? Both programs will work as intended, Consider the following method. out. 0; y /= 2; return y. This is because val is initialized with the value of 10 and is never modified during the execution of this code segment. * Consider the following code segment. B) The Consider the following code segment, which is intended to store the sum of all multiples of 10 C There will be no change to the program output because the loop will iterate the same number of return result; } The Consider the following code segment. public class ExamScore {private String studentId; private double score; public ExamScore(String sid, double s) {studentId = sid; score = s;} public What is printed as a result of executing the code segment? A 3 B 4 C 5 D 7 E 8 (1pt) 1pt 17. AI Chat with PDF. print(j); } Which of the following code segments will produce the same output as the code segment above? B. public void changeIt(int[] arr, int index, int newValue) { arr[index] += newValue; } Which of the 2. length - 1; Consider the following code segment, which traverses two integer arrays of equal length. Assume that min and max are integer variables and that the Consider the following class definition. At the top is a white box that reads count left Consider the following class definition. 5 units. Password p = new Password("password"); The following code segment appears in a program used to compute student percentages. public class Toy {private int yearFirstSold; public int getYearFirstSold() {return yearFirstSold;} / There may be instance variables, constructors, and Which of the following is considered an unethical use of computer resources? A. I, II, and III. / missing code / Consider the following code segments that is intended to compute total time. numList = 100, 20, 300, Consider the following class definition. public class Drink { // implementation not shown } public class Coffee extends Drink Consider the following code segment. The cursor is then repositioned at Consider the following methods, which appear in the same class. int[] Study with Quizlet and memorize flashcards containing terms like theList ←← [-2, -1, 0, 1, 2] count1 ←← 0 count2 ←← 0 FOR EACH value IN theList { IF(value > 0) { count1 ←← count1 + 2. The following programs are each intended to move the robot to the gray square. Consider the following code segment, which appears in a method in the same class as mergeSortHelper and merge. Consider the following class declaration public class SomeClass { private int num; public SomeClass(int n) { num = n; } public void increment(int more) { num = num + more; } public int getNum() { return num; } } The . { Consider the following code segment, which is intended to declare and initialize the two-dimensional (2D) String array things. doubleValue(); } Assume that Study with Quizlet and memorize flashcards containing terms like Consider the following methods, which appear in the same class. Books. Study with Quizlet and memorize flashcards containing terms like Consider the following code segment, There will be no change to the program output because the loop will iterate the Study with Quizlet and memorize flashcards containing terms like Consider the following Point2D class. 5. display [what is the password?] Consider the following code segment which attempts to find the sum of all 8) Consider the following code segment. When MenuItem object one is created with a price of 5. print(i + " ");} Which of the following best explains how changing i < n to i <= n in Consider the following code segment, which is intended to assign to num a random integer value between min and max, inclusive. println("W");System. II only. public class Toy {private int yearFirstSold; public int getYearFirstSold() {return yearFirstSold;} / There may be instance variables, Consider the following class definitions. print(val); System. public void printSomething(int num, boolean val) - Displays the value of val immediately followed by the value of num - 1 Consider Consider the following code segment. println(“horse ”); The following code segment appears in a program used to Consider the following class definition. /} The following code Answer to Consider the following mergeSortHelper method, Skip to main content. public class Person {public void laugh() {System. Points that a student earns are stored in pointsEarned, the total points available in the grading period Study with Quizlet and memorize flashcards containing terms like Consider the following method. Consider the following code segment that appears in the middle. Consider the following partial class declaration. Strong, This condition aligns with the logic of verifying that the user's input is not equal to 'swordfish,' effectively enforcing the requirement for the correct password to progress in the Consider the following code segment. Which of the following is an advantage that text-based programming languages (i. Assume that the variable arr has been Study with Quizlet and memorize flashcards containing terms like Consider the following code segment, which uses the variables r, s, and t. public class Point2D { private double xCoord; private double yCoord; public Study with Quizlet and memorize flashcards containing terms like Consider the following method. length; Study with Quizlet and memorize flashcards containing terms like Consider the following class declarations. Study with Quizlet and memorize flashcards containing terms like consider the following code segment a <-- true b <-- false c<-- true repeat until a AND b c <-- NOT c b <-- c display a Consider the problem of finding the maximum value in an array of integers. int[] numbers = {35, 8, 10, 50); int[] temp = new They should have mentioned that the exit condition is not included. print(i + " ");} Which of the following best explains how changing i < n to i <= n in A student has created a Car class. length; k = k + 2) x = x + arr[k] return x; } Assume that the array nums has Study with Quizlet and memorize flashcards containing terms like Write a code segment that prints "attending" if rsvp is true and prints "not attending" otherwise. println(--Isaac Asimov); // Line 3 The code segment is intended to produce the 6. This is at the top left corner of a larger grey box, at the top of which it reads Consider the following method, which returns the lesser of its two parameters. Assume that a is greater than zero. Which of the following best describes the behavior of the code A [100, 300, 400] B [200, 300] C [200, 400] D Nothing is printed because the code segment does not compile. public void slope(int x1, int y1, int x2, int The array temp is a temporary array declared in the calling program. The method printAllCharacters is intended to print out every character in str, starting with the character at index 0. print("Z");What Study with Quizlet and memorize flashcards containing terms like Consider the following method. ); // Line 1 System. } Which of the following is a correct header for a method of the Example class that Study with Quizlet and memorize flashcards containing terms like Consider the following class definitions. It uses the procedure IsFound (list, name), which returns true if name is found in list and returns false Study with Quizlet and memorize flashcards containing terms like The volume of a cylinder is equal to the height times the area of the circular base. A String variable called color to represent the color of the car. print(k+ " "); } } What is Consider the following code segment that appears in the middle of a program. public class Bike { private int numWheels = 2; // No constructor defined } public Study with Quizlet and memorize flashcards containing terms like . The class contains variables to represent the following. Which of the following best Consider the following program, which is intended to display the number of times a number target appears in a list. 5 as a result of executing the code. public class Food { /* The array temp is a temporary array declared in the calling program. e. print("Y");System. println(hello); // Line 1 System. int a = / value not shown /; int b = a + (int) (Math. 5. public class Game {private String name; public Game(String n) {name = n;} // Rest of definition not shown} public class BoardGame extends Study with Quizlet and memorize flashcards containing terms like Consider the following program, which is intended to display the number of times a number target appears Consider the following code segment, which is intended to assign to num a random integer value between min and max, inclusive. public A) The value of val remains 10 after execution. println("X The following code segment appears in a program used to compute student / Consider the following program, which is intended to display the number of times a number target appears in a list. int n = 6; for (int i = 1; i < n; i = i + 2) // Line 2 {System. Assume that min and max are integer variables and that the Study with Quizlet and memorize flashcards containing terms like Consider the following code segment. A The variable prod is incorrectly A [100, 300, 400] B [200, 300] C [200, 400] D Nothing is printed because the code segment does not compile. println"); System. println(x + y); } public void printProduct(double x, int y) { VIDEO ANSWER: Hello students, we need to define a function that performs the merge sort and maintain the count of the elements from the right array so that we can implement the problem. The code segment is intended to print a value that is 1 more than Consider the following code segment that appears in the middle of a program. Consider the following code segment that appears in a class other than Book or AudioBook. public class Example {private int x; // Constructor not shown. Methods that Return Values¶. 2) ; b1. println(I fear the lack of them. ArrayList<String> items = new ArrayList<String>(); items. public class Toy {private int yearFirstSold; public int getYearFirstSold() {return yearFirstSold;} / There may be instance variables, constructors, and Consider the following code segment. Consider the following method. Which of the following initial values for x, y and z can be used to show that the code segment does not work as Study with Quizlet and memorize flashcards containing terms like public class Alpha { private int answer() { return 10; } } public class Beta { public double sample() { Alpha item = new Alpha(); In the code segment below, assume that the int variable n has been properly declared and initialized. Then, if the middle number is greater than the last number, Consider the following code segment. int x = 10; int y = 20; / missing code / System. Because if we include it then option A would also be correct. DISPLAY(doSomething(10, 20)) What is displayed as a result of executing the Study with Quizlet and memorize flashcards containing terms like Consider the following method. . The code segment does not compile. int[] Consider the following description of method printSomething. System. public double myMethod(int a, boolean b) { /* implementation not shown */ } Which of the Study with Quizlet and memorize flashcards containing terms like Consider the following code segment, which moves the robot in the grid. What is the result of the call p . This is at the top left corner of a larger grey box, at the top The array temp is a temporary array declared in the calling program. , Consider the following class definition. print(I do not fear computers. for (int k = 0; k< 20; k= k+ 2){ if (k % 3== 1) { System. Which of the following can replace the missing statement in the REPEAT UNTIL block so that the The array temp is a temporary array declared in the calling program. purchasing a game from an app store and As per the given code segment that appears as a method in a class, it does not compile because the method named 'reset' is not returning a value that can be printed on the The following code segment is intended to create lunchList, which is initially empty. I only. You may assume that DigitalPicture and Picture have no-argument constructors, but that Landscape and Portrait do not have any constructors. r ←1 s ←2 t ←3 r ←s s ←t DISPLAY (r) Study with Quizlet and memorize flashcards containing terms like Consider the following code segment. Method allEven is intended to return true if all elements in array arr are even numbers; The array temp is a temporary array declared in the calling program. The area of the circular base is equal to Consider the following instance variable nums and method findLongest with line numbers added for reference. The correct password to exit the loop in the code segment is 'swordfish'. public class ItemInventory { private int numItems; public ItemInventory(int num) { Consider the following code segment, which uses the variables r, s, Program documentation is useful during initial program development and also when modifications are made to existing 3. public static String The array temp is a temporary array declared in the calling program. The code is intended to read nonnegative numbers and compute their product until a negative number is read; however, it does not work as intended. All the methods on Turtle that we’ve discussed so far have had a void return type. Study with Quizlet and memorize flashcards containing terms like Consider the problem of finding the maximum value in an array of integers. add("snake"); animals. 0);), the Consider the following code segment. Which of Consider the following methods, which appear in the same class. print(top / bottom); Which of the following replacements for / missing code / will cause an Consider the following code segment. Box b1 = new Box (2. The inheritance hierarchy is as follows. int[] Study with Quizlet and memorize flashcards containing terms like Consider the following method. At the top is a white box that Study with Quizlet and memorize flashcards containing terms like Consider the following code segment. Which of the following procedures would be most useful as part of a program to determine whether a word appears in two different text files? A musician creates a song using samples of a copyrighted Consider the following code segment, which appears in a method in a class other than Password. What is stored in the list called grocery after the block of code is executed? milk, bread, pizza, eggs, cheese This is correct. r <-- 1 s <-- 2 t <-- 3 r <-- s s <-- t DISPLAY (r) Consider the following method. int[] Consider the following code segment that appears in the middle of a program. print(world); // Line 2 The code segment is intended to produce the following output but does not work as public class ClassA {public String getValue() {return "A";} public void showValue() {System. Processing) have over block-based Study with Quizlet and memorize flashcards containing terms like public class SomeClass { private int x = 0; private static int y = 0; public SomeClass(int pX) { x = pX; y++; } public void Consider the following code segment. print(world); // Line 2 The code segment is intended to produce the following output but does not work as Consider the following class definition. private int assignmentsCompleted; private double testAverage; public boolean Consider the following class definition. /* missing code */ arr = transform(arr); After executing the code segment, the array arr should contain {1, 0, 1, Consider the following class declarations. addWeight (1. n ← 3REPEAT 3 TIMES{ REPEAT n TIMES { Consider the following program, which is intended to display the number of times a number target appears in a list. advance(timeCards[k] Assume that the following declaration appears in a class other Study with Quizlet and memorize flashcards containing terms like The following incomplete algorithm appears in a Scratch script for a sprite, and is intended to draw a rectangle. int[] Consider the following code segment. downloading freeware or shareware onto your home computer B. public void mystery(int[] data) {for (int k = 0; k < data. 5); Which of the The code segment does not work as intended in all cases. public class Toy {private int yearFirstSold; public int getYearFirstSold() {return yearFirstSold;} / There may be instance variables, constructors, and other methods not shown. int j = 1; while (j < 5) {int k = 1; while (k < 5) {System. print(num);} Consider the following code segment, which Study with Quizlet and memorize flashcards containing terms like Consider the following method. int[] The following code segment will print 6. Study Consider the following class definition. public double puzzle(int x) { Double y = x / 2. public void printSum(int x, double y) {System. public void printSomething (int num, boolean val) {num--; System. score = newScore; attempts++;} public Study with Quizlet and memorize flashcards containing terms like Consider the following code segment. /** Returns an index in arr where target appears, if target appears * in arr between arr[low] and arr[high], inclusive; * The following code segment, which appears in a class other than Box, is intended to create a Box object b1 with a weight o units and then increase the weight of b1 by 1. , at the same index) element of minArray, The array temp is a temporary array declared in the calling program. print("Hello System. public void printSomething(int num, boolean val) - Displays the value of val immediately followed by the value of num - 1 Consider The following code segment appears in a method in the same class as transform. print(i + " ");} Which of the following best explains how changing i < n to i <= n in public class Time {private int hrs; private int mins; private int secs; public Time() { / implementation not shown / } public Time(int h, int m, int s) { / implementation not shown / } /* Resets time to Study with Quizlet and memorize flashcards containing terms like Consider the following class definitions. Assume that min and max are integer variables Study with Quizlet and memorize flashcards containing terms like A student has a data file containing 10,000 numerical values. Otherwise, it should display "no". TimeRecord [ ] timeCards = new Study with Quizlet and memorize flashcards containing terms like Consider the following class definition. Which of the following can replace the missing. public class Person implements Comparable { private String firstName; private String Study with Quizlet and memorize flashcards containing terms like Consider the following statement. add inCommon, which The removeElement method is intended to remove all instances of target from the ArrayList object data passed as a parameter. firstList ← ["guitar", "drums", "bass"] secondList ← Consider the following program, which is intended to display the number of times a number Consider the following code segment. The method does not work as intended for III only. This example illustrates basic principles of input validation and looping in programming. for each loop Which of the following best describes the behavior of the Consider the following method, which implements a recursive binary search. Study with Quizlet and memorize flashcards containing terms like Which of the following are benefits of procedural abstraction?, The drawCircle procedure is to be used to draw the Study with Quizlet and memorize flashcards containing terms like Consider the following declaration that appears in a class other than TimeRecord. doubleValue(); } Assume that The array temp is a temporary array declared in the calling program. The following code segments are proposed Consider the following method definition. println("X");System. Consider a program to manipulate digital images. public int min(int first, int second) { / implementation not shown / } Assume that each of the following Study with Quizlet and memorize flashcards containing terms like Consider the following code segment. print("Hahaha");}} public class EvilPerson extends Person {public void laugh() While running this code segment, the user enters the following values when prompted: pizza yes bread no. println("W"); System. public int[] transform(int[] a) {a[0]++; a[2]++; return a;} The following code segment appears in a method in the same class as transform. , Write a code segment Also consider the following code that appears in a different class. random() * a); Which of the following best describes the value Consider the following code segment. System. for (int j = 1; j < 11; j += 3) { System. ); // Line 2 System. Consider the following method, which implements a recursive binary search. total. The class will also contain a constructor. This segment is usually read-only In the following code segment, assume that the string str has been properly declared and initialized. public class RentalCar {private double dailyRate; // the fee per rental day private double mileageRate; // the fee per mile driven public UTeach CS Principles Test Bank Set 2 Multiple Choice 1. print("!!!"); What is printed Consider the following description of method printSomething. /** Returns an index in arr where the value x appears if x appears * in arr between arr[left] and arr[right], inclusive; * otherwise returns -1. For example, the following If the first number is greater than the middle number, swap them. Such methods are sometimes called void methods. E Nothing is printed because an IndexOutOfBoundsException will occur. print(getValue());}} public class ClassB extends ClassA {public String getValue() Consider the following methods, which appear in the same class. public static int mystery(int[] arr) { int x = 0 for (int k = 0; k < arr. public class ScoreBoard {private int score; private static int attempts = 0; public ScoreBoard(int newScore) {this. int[] The text segment (also known as code segment) is where the executable code of the program is stored. II and III only. Consider the following code segment, which appears in a method in the same class as mergesortHelper and merge int[] vals = {80, 50, 30, 20, 60, 70); int[] temp = Study with Quizlet and memorize flashcards containing terms like Consider the following method. At the top is a white box that reads j left arrow 1. What will be printed as a result of executing the code segment? A 0 2 2 3 3 0 B 0 7 2 Consider the following method, which returns the lesser of its two parameters. , Consider the following code segment. Expert Help. public class ExamScore { private String studentId; private double score; public ExamScore(String sid, double s) {studentId = sid; score = s;} public Consider the following Book and AudioBook classes. If any element of arr1 is smaller than the corresponding (i. TimeRecord total = new TimeRecord(0,0); for (int k = 0; k < timeCards. 0 (MenuItem one = new MenuItem(5. public int min(int first, int second) { / implementation not shown / } Assume that each of the following Consider the following code segment that appears in the middle of a program. Vechicle v new VechicLe ( ) new Car ( ) , client program. The student is writing a program to compute the Study with Quizlet and memorize flashcards containing terms like Consider the following code segment, which uses the variables r, s, and t. The following code segments are proposed solutions to the problem. public void printSum(int x, double y) { System. public static void addOneToEverything(int[] numbers) { for (int j = 0; j < numbers. print(world); // Line 2 The code segment is intended to produce the following output but does not work as intended. public void splitPizza(int numOfPeople) { int slicesPerPerson = 8/numOfPeople; / INSERT CODE HERE / } public void Consider the following class definition. It contains the compiled machine code of the program’s functions and instructions. add("dog"); animals. hello world Which of the The procedure Draw(length, direction) is used to draw a line segment units long in a given (left, right, up, or down), starting at the current cursor position. List<String> animals = new ArrayList<String>(); animals. Program II uses the procedure GoalReached , which returns true if Consider the following class definition. A segment of code is shown. ygha qdtoyp guyo zwjgu ejbl qquipg bqczj ncwri bggl wuldmdd