OC userin Computer Science·13 Jun 20187. Enter the best choice from the list of choices A-W above for what this program displays void setup() { frameRate (10); int limit=0; void draw() { background (255); if (limit > mousex || limit > mousey) limit = 0; for(int col = 0; col <=limit; col = col + 20) for (int row = 0; row <= limit; row – row + 20) rect (row, col, 20, 20); limit = limit + 20;
OC userin Computer Science·14 Jun 201815. What does the following program print? int count = 0; int[] data = {10,0,-15, 0, 12, -7,0,14); for (int i = 0; i < data.length-1; i++) { if (data[i]
OC userin Computer Science·13 Jun 20185. When iterating through the elements of array via its index, you must use a for loop as opposed to a while loop.
OC userin Computer Science·13 Jun 201835. Why do we check on line 20 of code 5 that nodel is not equal to node2? N.B. reread the header of this section. (A) To check if nodel is neighbour with node2 (B) It serves no real purpose (C) The code is wrong is should be if (nodel == node 2) (D) We want to make sure that we do not connect a node to itself (E) To avoid an infinite loop
OC userin Computer Science·13 Jun 201832. (2 points) Use an if-statement to create a program that shows a diameter 20 circle moving diagonally from the upper left corner to the center where it then stops and stays in the center.
OC userin Computer Science·12 Jun 20184. Consider the following program. public class Fraction { private int numerator; private int denominator; public Fraction (int n, int d) { numerator = n; denominator = d; public Fraction add (Fraction f) return new Fraction (numerator * f.denominator + 1. numerator * denominator, denominator + f.denominator); public Fraction add (int x) { return new Fraction (numerator + x denominator, denominator); public Fraction add (int n, int d) return new Fraction (numerator denominator * d); d+n* denominator, public String toString() { return numerator + "/" + denominator; public static void main(String[] args) { Fraction f1 = new Fraction (1, 2); Fraction f2 = new Fraction (2, 3); Fraction f3 = new Fraction (3, 4); Fraction sums = new Fraction [4]; sums [0] - fl.add(f3); sums [1] - f2.add(f3); sums [2] - fl.add(1); sums [31 - f2.add(3, 3); for (int i = 0; i <= sums.length; i++) { System.out.println(sums[i].toString()); The above program compiles without error; what does it display when it is executed?
OC userin Computer Science·12 Jun 201821. Suppose a process, P1, is running and the operating system uses the Paged Memory Management technique. Assume P1 has the following page-map table (PMT), and that the page size and the frame size are the same, each being 1024 bytes long. Assuming all addresses start from 0, the logical address 2564 is mapped to the physical address _, where (Frame X, offset Y) means byte number Y in Frame number X. Page Frame | 22 56 98 | 12 60 a) Frame 2, offset 516 b) Frame 98, offset 516 x c) Frame 2, offset 500 d) Frame 98, offset 0 e) None of the above
OC userin Computer Science·10 Jun 201818. How many times is the condition in the inner loop evaluated?
OC userin Computer Science·10 Jun 201827. Consider the Cocktail Sort (code 4) algorithm described in the appendix. If we input the same array (a = {3,4,2,6,1}), what will be printed by the print statement on line 28 the first time it is executed? (A) (3,2,4, 1,6] (B) (1,3,2,4,6] (C) (1,2,3, 4, 6] (D) Nothing (E) [2,3,4, 1,6]
OC userin Computer Science·9 Jun 2018True false questions (1 point each) In the following questions answer A for true or B for false. 38. In Java, methods can be defined inside of other methods. (A) FALSE (B) TRUE
OC userin Computer Science·7 Jun 201820. The Partition Memory Management technique requires the use of Base and Bound registers to a) Hold the beginning address and the length of the partition for the current process. X b) Hold the program counter and accumulator for the current process. c) Hold the number of processes running in the partition and the maximum number of processes that can be run in the given partition. d) Hold the amount of memory used and maximum memory needed by the current process. e) None of the above
OC userin Computer Science·8 Jun 201820. How many times does the letter D print in the following code? for (int i = 0; i < 3; i++) { for (int j = i+1; j < 3; j++) System.out.println("D"); { (A) 3 (B) 0 (C) 6 (D) 1 (E) 2
OC userin Computer Science·8 Jun 20188. Enter the best choice from the list of choices A-W above for what this program displays // caution - this may be a trick question int ballpos = 0; int ballDirection = 1; void draw() ! background (255); int ballSize = 10; fill(0); ellipse (width/2, ballpos, ballsize, ballSize); ball Pos - ball Pos + ballDirection; if (ball Pos < 0 ball Pos > 100) { ballDirection = ball Direction* (-1);
OC userin Computer Science·7 Jun 201826. Consider the Cocktail Sort (code 4) algorithm described in the appendix. If we input the array a = {3,4,2,6,1}, what will be printed by the print statement on line 15 the first time it is executed? (A) (3,2,4, 1,6] (B) (1,2,3,4,6] (C) (3, 2, 4, 6, 1] (D) Nothing (E) [3, 4, 2, 1,6]
OC userin Computer Science·7 Jun 20182. How many times is the condition of the while loop checked in the following code? int i = 0; while (i < 10) { System.out.println("Repeat!"); i++; (A) 11 (B) 1 (C) 0 (D) 9 (E) 10