OC userin Computer Science·6 May 2018Part (b) [3 MARKS] Complete the function body according to its docstring description. You will be marked only on the parts that need to be different from (a). def count_letter_case_mutate (L): " (list of list of str) -> None Type Precondition: each str in L is non-empty and contains only alphabetic characters Replace each item in L with a two-item tuple in which the first item is the number of words in the list at the corresponding index of L that start with a lowercase letter and the second item is the number of words in the list at the corresponding index of L that start with an uppercase letter >>> data = [['apple', 'Banana'], ['PeAr'], [], ['PEACH', 'aprICot', 'plum']] >>> count_letter_case_mutate (data) >>> data [(1, 1), (0, 1), (0, 0), (2, 1)]
OC userin Computer Science·2 May 2018What goes in the blank so the display is black when the mouse is left of the center and white when it is to the right of the center? void draw() { A. mousex < 50 background (255); B. mousex > 50 if ( c. mousex != 50 background(0);
OC userin Computer Science·1 May 20186. The Boolean expression corresponding to the following logic circuit is lo lo a) AB + ACX b) B(A + C) c) ABC d) AB + C e) None of the above
OC userin Computer Science·1 May 20182. In this section you will be shown several classes. Inside the code for each class will be a question. You should provide your answer to the question inside the chart. Many of the questions will ask you whether a variable has changed or not. In cases that the variable being asked about is a primitive type, you should provide your answer based on the data stored in the primitive type. In cases that the variable being asked about is a reference type, you should provide your answer based on the data stored at the Object linked to by the reference type. For example, in the first snippet, the question asks about the variable x defined in the main method. Since x is a primitive type, you should answer YES if you think the variable x has had its value changed after the method methodOne() returns. All your answers should go in the chart below: (9 points) Part Answer to question x changed (circle one)? YES NO y changed (circle one)? a changed (circle one)? b changed (circle one)? d1 a changed (circle one)? b changed (circle one)? YES e words changed (circle one)? YES NO Values in array of array referred to by y: What is printed to the screen? (a) public class ReferenceTesti public static void methodOne (int x){ x++; public static void main(String[args) { int x = 0; methodOne (x); //IS THE DATA STORED OR REFERRED TO BY X THE SAME? (ANSWER IN CHART)
OC userin Computer Science·2 May 20182. What is displayed by this program in frame 2 and beyond? int x = 0, y = x; void draw() { A. An empty white background (255); display. while ( x < width) { C.One 10x10 square in rect (x, y, 10, 10); the lower right x = x + 10; corner. B.A diagonal line of 10x10 squares. D. A row of 10x10 squares along the top edge. x = 0;
OC userin Computer Science·29 Apr 2018COMP 2021Winter 2010 - Final Examination Pape 11 110 6 . The two classes low compile without me. What is displayed when the main() method of class Nightmareix is executed? Clearly indicate the program output in the appropriate space ca pe You may use the other lank space as a scratch pad to track the state of memesy as the program escoles, but the contents of this other space will not he graded The definition of the Pair claw public cla Pair private int left: private int right publie Pairintit T left- right - public void nix (Pair pl loft - P.left public string toitring) return "IL... lort R right "1" The definition of the NightmareMix class public class Nightmareix public static void mix Inta (int il, int 12) public static void mixArraywithint fint 11 a, int i, int v) 11 - V public static void mixArrayaor Int(int il al, intl a2) public static void mixMatrixWithint fint 11111121 - m int 11, int 12, int v public static void mixMatrix WithArray (int 11 11- , int i, intila) public static void mixlar Addresses Pair pl, Pair 2) pl - p2 public static void mixArrayWithPairState (Pair) a, int i, Pair pl public static void mixArrayWithPairAddress (Pairla, int i, Pair p) ali - P; public static void mixArrayaoraira (Pairil al, Pairil a2) public static void main(Stringil arga) int myV1 - 1; int myV2 - 2; int my = (3, 4) int my2 = 5, 6) into myM1 , 8 9, 10}} Pair myP1 = new Pair (11, 12) Pair myP2 = new Pair (13, 14) Pair myPA (neu Pair (15, 16), new pair(17, 18) Pair myPA2 = (neu Pair (19, 20), new pair (21, 22) mixInita (myvi, myV2); mixArrayWith Int (myal, 0, myv2); mixArraysOfIntinyal, myA2); MixMatrixWithint (myM, 0, 0, myV2); mixArrayaofTnt (HyMIO, myM[1); mixMatrixWithArray (wy, , WyA2); mixArraywithint nyA2, 0, myV2); mixPair Addresses (wypi, myP2); RixPairAddren (HyPALIO), WPAI[1]); mixArraywithPairstate (myPA2, 0, 1); mixArraywithPairAddresa (myPA2, 1, WP2); mixArray Paira (wyPal, myPAZ) System.out.println("1.. myvi) System.out.println("2: ( +WA110 A11] + " ") System.out.println("3: ( + myA2[0] + + m 2 (1) + " ); System.out.println("4: ( myM[0][0] + "," myM[0][1] + " myM[1][0] + " " + myM[1][1] + "} ") System.out.println('5: ( + myPA10) + myPA [1] + " "); System.out.println("6: ( myPA2[0 PA21] + " ); 1"
OC userin Computer Science·1 May 201816. Suppose m and n are both int variables with positive values. Which of the following boolean expressions are guaranteed to be equal in value to the expression that follows? (m % n == 0 && n % m == 0) • I. m == • II. ! (m III. ! (m n n) > n) (A) I and III (B) I, II, and III (C) I and II (D) None of the expressions are guaranteed to be the same. (E) I only
OC userin Computer Science·30 Apr 201817. What does the following program print? void setup() { int x = 10; printval (x); printval (20); println(x); void printval (int x) { println (x); x = 0;
OC userin Computer Science·27 Apr 201814. (1 point) How many times does the following program print "testing? (put answer here) int i = 1; if (i < 20 ) { while (i <= 30) { println("testing"); i = i + 1;
OC userin Computer Science·28 Apr 201813. What prints when the following method executes? public static void method() { int n = 5; if (n>0){ System.out.print("one "); n=0; if (n<=0) { System.out.print("two "); else { System.out.print("three ");
OC userin Computer Science·25 Apr 20184. For A and B in the truth table of the operator ? above represents: a. A ORB b. A AND B C. A AND GB) d. A XOR B
OC userin Computer Science·26 Apr 201817. What expression can you put in the blank so this program shows a circle falling from the top center to the middle and then stopping when it reaches the center of the display staying there for 50 frames and then moving back up and off of the screen? A. frameCount/(height/2) int bally = 0; B. frameCount: (height/2) void draw() { C. (1-(frameCount/(height/2))) background(120); D. (1-(bally/(height/2))) bally = bally + E. bally/(height/2) ellipse(width/2, bally, 20, 20);
OC userin Computer Science·26 Apr 201827. Ethernet is a medium access control standard a. Local Area Network (LAN) b. Wide Area Network (WAN) c. Wireless Local Area Network (WAN) d. Personal Area Network (PAN)
OC userin Computer Science·23 Apr 2018(c) Consider the following class: public class Student Grades private int ( grades; 1/loads values into grades from a file public void initializeFromFile(String filename) ....! //gets the total number of grades entered public int get NumRecords () (....) public class WebCT 1 public static void main(String[] args) Student Grades grades = new Student Grades(); grades.initializeFromFile("records. L.sv"); System.out.println("There are " + grades.length file.") " grades in that The goal of the program is to load the files and then print the total number of grades in the file. However, when you try to compile the above classes, you get the following error: WebCT.java:5: cannot find symbol symbol : variable length location: class Student Grades System.out.println("There are " + grades.length + " grades in that file." Explain why the crror occurs and write the code to fix it (while maintaining the intended functionality).
OC userin Computer Science·22 Apr 201821. Given the array declaration int( scores – new int[70]; fill in the blank so the print statement prints what is stored in the last element of the array: println( A. scores[69] B. scores[70] C. scores.length D. scores.last E. last(scores) _);?