OC userin Computer Science·8 Mar 201817. An operating system manages numerous, concurrently running programs known as processes. A process control block (PCB) is a data structure that can hold a) the value of the program counter b) the values of all registers c) accounting information about the current process d) All of the above x e) None of the above
OC userin Computer Science·6 Mar 201850. Line 6 (A) return counter; (B) counter++; (C) while (current.getNext() == null) { (D) counter = counter + current.getValue(); (E) start = null;
OC userin Computer Science·7 Mar 20186. Inside a class, you can declare multiple methods with the same name, and the same input arguments, provided that all such methods have a different return type. (A) FALSE (B) TRUE
OC userin Computer Science·6 Mar 201835. (2 points) Write a method/function named fact that computes n! (n factorial). Recall that n! is nx (n-1)(n-2)... x 2x1 for n greater >0 and ! is 1. You can assume your method is only passed non-negative values of n.
OC userin Computer Science·6 Mar 2018Short Answer & Multiple Choice (2 points each) For all of the 'what prints' questions in this section, if you believe that nothing will print as a result of exe- cuting the sample code, write 'N/A. We are not evaluating the difference between System.out.print and System.out.println 9. What is the value of x? double x = (double) (1/2) + (1/2) + (double) (1/2);
OC userin Computer Science·5 Mar 20188. What is printed by the following code? String strl = null; String str2 = "abc"; System.out.println(str2.equals("abc") && stri.equals (null)); (A) TRUE (B) FALSE
OC userin Computer Science·4 Mar 20189. 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 XPOS, Y POS; void setup() { y Pos = 0; xPos = width/2; void draw() { background (255); int ball Size = 10; fill(0); ellipse (xPos, ypos, ballSize, ballSize); yPos = y Pos + 1; xPos = xPos + y Pos/(height/2);
OC userin Computer Science·2 Mar 201819. (2 points) Given the Rocket class from program 6 which includes instance variables xVel and yvel, write a method called safeLanding () that could be added to the Rocket class and returns true if the rocket made a safe landing and false otherwise. Assume the rocket has landed and you are only deciding if it was a safe landing or not. A safe landing is one in which both the x and y velocities are between -0.4 and 0.4. class Rocket { float xVel, yvel; // most of the class is omitted and not needed for this question // put your safeLanding method here
OC userin Computer Science·4 Mar 20188. We use transistors to construct gates, the diagram below represents the gate. Source Emitter Ground a. NOT b. AND c. OR d. XOR
OC userin Computer Science·1 Mar 201855. Line 3 (A) for (int j = height; j< height - i; j+-height) { (B) for (int j = 0; j< 2 + height; j+=height) { (C) for (int j = 0; j< height - i * 2; j++) { (D) for (int j = 0; j< height - i-1; j++) { (E) for (int j = 0; j< height ; j++) {
OC userin Computer Science·1 Mar 201812. What does this program print? The function print() is like println() except that it does not print a new line character after printing the value so if more than one of the print() statements executes all output will be on one line int x = 10, y = 10, z = 5; if (x == y) { print ("A"); A. A if (x > 2) B. AB print("B"); C. ABC D C else if (y > 2) E. AC print("C");
OC userin Computer Science·27 Feb 2018Recursion Question 5. In the following question, you will be asked to program the following using recursion. If you have an iterative solution, you may use it, but the most you can get for the question will be half credit. (5) points) Consider the following mathematical function h which operates on integers. (1, if n < 2 h(n) = n(n-1) +n if n > 2 and n is even han -2) +2*n if n > 2 and n is odd In Java, use recursion to write a method h which takes as input an int n and returns h (n). public static int h(int n) {
OC userin Computer Science·1 Mar 2018Part (e) [1 MARK) What additional piece of information do you know about the sorted section during selection sort that you don't know during insertion sort?
OC userin Computer Science·27 Feb 201816. What prints when the following snippet of code is executed? int[] foo = {1,2,3); int() foo2 = foo; int[] bar = {1,1,1); foo2 [1] = 1; bar[2] = 3; System.out.print (foo [1]); System.out.print(" "); System.out.println(foo == bar);