APCS

Ace your homework & exams now with Quizwiz!

What are the arithmetic operators (add, subtract, multiply, divide) in Java, respectively? Question 54 options: +, -, x, / +, -, x, % +, -, *, / add, subtract, multiply, divide

+ - * /

What is output by the code below? for(int e=1; e<3; e++) System.out.print(e); Question 108 options: a) 4321 b) 1234 c) 123 d) 12345 e) 12

12

What is output by the following code? String s = "Computer Sci"; System.out.println(s.length( )); Question 43 options: illegal code 12 None of these 13 14

12

What is the value of the arithmetic expression: data[2] + data[6]?

23

What is output by the code below? int numE=100, numF=10; if(numE > 90) if(numF > 10) out.print("go"); else out.print("run"); else out.print("fly"); out.print("nogo"); Question 95 options: nogo go fly run runnogo

runnogo

What is output by the code below? int f = 7; if(f >= 5) out.print("same"); else out.print("notsame"); out.print("done"); Question 100 options: samedone notsame notsamedone done same Save Previous PageNext Page

samedone

What is output by the code below? int g = 5; if(g == 5) out.print("same"); else out.print("notsame"); out.print("done"); Question 101 options: done notsamedone notsame samedone same

samedone

Which of the following corresponds to the constructor body for a Square class that accepts an initial side length value where the instance variable is named sideLength? Question 39 options: sideLength = initialLength; initialLength = sideLength; initialLength = 0; sideLength = 0; Save Previous PageNext Page

sideLength = intialLength;

What is output by the code below? String c = "abc"; if(c.equals("ABC")) out.println("same"); Question 92 options: 789 ABC abc there is no output same Save Previous PageNext Page

there is no output

Assuming the following code fragment, what is the value of tt? String t = "2"; String tt = t + t; What is the value of t? Question 73 options: The code fragment has a syntax error and does not compile. "4" "22" 22

"22"

What is the Java operator that computes the remainder of an integer division? Question 55 options: % mod / div

%

What is output by the code below? String st_C = "abc"; String st_D = "ABC"; out.println(st_D.compareTo(st_C)); Question 87 options: 0 -2 -1 -32 32 Save Previous PageNext Page

-32

What is output by the code below? System.out.print(4 % 3); Question 29 options: .5 1 2 0 3 Save Previous PageNext Page

1

What is the length of the array data?

10

What is output by the code below? for(int f=1; f<5; f++) { System.out.print(f); } Question 105 options: a) 123 b) 1234 c) 12 d) 12345 e) 4321 Save Previous PageNext Page

1234

What is the output? for(int i=1; i<6; i=i+2) { out.print(i); } Question 126 options:

135

What is output by the code below? public class Check { private int one, two, total; public void setNums(int n1, int n2) { one = n1; two = n2; } public void add() { total = one + two; } public String toString() { return "" + total; } } //code in the main of another class Check test = new Check(); test.setNums(9,7); test.add(); out.println(test); Question 31 options: 0 12 14 16 2

16

What is the output? int sum=0; for(int m=1; m<8; m++) { if(m%2==1) sum=sum+m; } out.println(sum); Question 125 options:

16

Which is a valid number literal? Question 60 options: 1x10^4 1E4 3 1/2 10,000 Save Previous PageNext Page

1E4

How many accessor methods are there in class It? public class It { private int myX; public It() { myX = 99; } public int getX() { return myX; } public String toString() { return "" + getX(); } } Question 32 options: 0 1 2 3 4 Save Previous PageNext Page

2

What is returned by the call go(4)? public static String go( int k ) { if(k >= 3) { if(k >= 6) return "3"; else return "2"; return "1"; } return "0"; } Question 98 options: 0 10 210 20 2

2

What is the output? int total=0,i; for(i=1; i<8; i++) { total=total+i; } out.println(total);

28

How many items are in the array? int [] temps = new int [3];

3

What is output by the code below? int cnt=0; for(int a=0; a<10; a=a+4) { cnt++; } out.println(cnt); Question 103 options: a) 2 b) 3 c) 4 d) 6 e) 5

3

What is returned by the call go(1)? public static String go( int k ) { if(k >= 2) return "1"; if(k >= 7) return "2"; return "3"; } Question 88 options: 13 2 1 3 12 Save Previous PageNext Page

3

What is returned by the call go(15)? public static String go( int k ) { if(k >= 10) return "3"; if(k >= 5) return "2"; return "1"; } Question 93 options: 32 21 31 3

3

What is output by the code below? int mark=0; for(int b=0; b<10; b=b+3) { mark++; } out.println(mark); Question 107 options: a) 2 b) 6 c) 5 d) 4 e) 3

4

What is the output of the following code: Circle c1 = new Circle(3); Circle c2 = c1; c1.setRadius(4); System.out.println(c2.getRadius()); Question 66 options: 4 3 6 8 Save Previous PageNext Page

4

What is ouptut by the code below? int counter=0; for(int c=0; c<10; c=c+2) {counter++; } out.println(counter); Question 104 options: a) 5 b) 2 c) 6 d) 4 e) 3

5

What is output by the code below? System.out.println( Math.sqrt(81) ); Question 30 options: 6.0 7.0 8.0 9.0 27.0 Save Previous PageNext Page

9.0

Fill in the blank for this algorithm for filling in initial values. for (int i = 0; __________; i++) { data[i] = i; } Question 17 options: A) i < data.length B) i <= data.length() C) i <= data.size() D) i < data.size

A

What is the error in this array code fragment? double[] data; data[0] = 15.25; Question 6 options: A) The array referenced by data has not been initialized. B) A two-dimensional array is required. C) An out-of-bounds error occurs. D) A cast is required.

A

What is the output of the following array code fragment? String[] players = {"Harry", "Sally", "Jeremy", "Cameron"}; for (String p: players) // process each player; System.out.println("The last player is: " + p); Question 13 options: A) None because the code does not compile. B) Cameron C) None due to an out-of-bounds error. D) None because the code is missing a new operator.

A

What relation does > test? Question 78 options: A) greater than B) greater than or equal to C) less than or equal to D) less than

A

When an array is created, all elements are initialized with ___. Question 4 options: A) a fixed value that depends on the element type B) null C) array elements are not initialized when an array is created D) zero

A

Which is the appropriate loop construct to print out the names in a partially filled array String[] names? Question 16 options: A) for (int i = 0; i < namesSize; i++) System.out.println(names.get(i)); B) for (int i = 0; i < names.size; i++) System.out.println(names.get(i)); C) for (String s : names) System.out.println(s); D) for (int i = 0; i < names.length; i++) System.out.println(names.get(i)); Save Previous PageNext Page

A

a primitive wrapper class is a wrapper class that encapsulates, hides or wraps data types from the eight primitive data types, so that these can be used to create instantiated objects with methods in another class or in other classes. The wrapper class for the primitive type double is ____________________. Question 8 options: A) Double B) Doub C) doubleObject D) There is no wrapper class.

A

What is an object? Question 48 options: A sequence of instructions. Any value stored in a variable. An entity in your program that is manipulated by calling methods. Any input to a method.

An entity in your program that is manipulated by calling methods

Identify the part of the line of code. Question 20 options: A) array type B) storage type C) reference variable D) bounds error Save Previous PageNext Page

Array type

Identify the part to the line of code. Question 21 options: A) array type B) reference variable C) primitive type D) error type

B

What is the returned by the call go(-6) ? public static int go(int x) { if( x > 0 ) return 1; return 2; } Question 83 options: A) 12 B) 2 C) 1

B

What term is used to describe the automatic conversion between primitive types and the corresponding wrapper classes? Question 11 options: A) casting B) auto-boxing C) auto-unboxing D) converting Save Previous PageNext Page

B

Which of the following is the assignment operator? Question 77 options: A) > B) = C) == D) <

B

Which of the following is the not equal to operator? Question 81 options: A) >= B) != C) == D) = Save Previous PageNext Page

B

Which statement declares and initializes an array variable with odd numbers less than 10? Question 5 options: A) int[] odd = [ 1, 3, 5, 7, 9 ]; B) int[] odd = { 1, 3, 5, 7, 9 }; C) int() odd = [ 1, 3, 5, 7, 9 ]; D) int() odd = { 1, 3, 5, 7, 9 };

B

With a __________________ array, keep a companion variable to track how many elements are used. Question 15 options: A) empty B) partially filled C) parallel D) uninitialized

B

Wrapper objects can be used anywhere that objects are required instead of ____. Question 10 options: A) generic classes B) primitive data types C) clone methods D) array lists

B

The following picture is a example of which of the terms? Question 19 options: A) bounds error B) null C) sort D) array list Save Previous PageNext Page

Bounds error

Consider the following syntax: for (typeName variable : collection) statement This is called a(n) ______________ for loop. Question 12 options: A) elegant B) element C) enhanced D) extended

C

String st_H = "abcabc"; st_H=st_H.replaceAll("c","-"); out.println(st_H); Question 85 options: A) -bc-bc B) bcbc C) ab-ab- D) abc-abc

C

What is returned by the call&nbsp; go("or")? public static String go( String s ) { if(s.length()>5) return s.substring(2,4); if(s.length()>1) return "" + s.charAt(1) + s.charAt(s.length()-1); return s; } Question 84 options: A) or B) ror C) rr D) ro Save Previous PageNext PagePage 84 of 160

C

What relation does <test? Question 79 options: A) less than or equal to B) greater than or equal to C) less than D) greater than Save Previous PageNext Page

C

What relation does == test? Question 80 options: A) greater than B) less than or equal to C) equal to D) greater than or equal to Save Previous PageNext Page

C

Private instance variables ___. Question 37 options: can only be accessed by methods of a different class can only be accessed by methods of the same class cannot be accessed by methods of the same class can only be accessed by the constructor of the class Save Previous PageNext Page

Can inly be accessed by methods of the same class

What is the term that means to explicitly convert a value to a different type? Question 34 options: case overflow rounding cast

Cast

What is the type of an object? Question 49 options: method reference class variable Save Previous PageNext Page

Class

Numerical ____________________ are values that do not change and that have a special significance for a computation. Question 53 options: constants statics comments commands Save Previous PageNext Page

Constants

A primitive wrapper class is a wrapper class that encapsulates, hides or wraps data types from the eight primitive data types, so that these can be used to create instantiated objects with methods in another class or in other classes. The wrapper class for the primitive type int is ____________________. Question 9 options: A) Int B) There is no wrapper class. C) intObject D) Integer Save Previous PageNext Page

D

Arrays suffer from a significant limitation because ____. Question 7 options: A) you cannot copy values from one array to another B) you cannot determine the number of elements in the array C) index values range from 0 to length + 1 D) their length is fixed

D

Identify the part to the line of code. Question 22 options: A) array errors B) reference size C) array type D) array size Save Previous PageNext Page

D

What is the output of the following code fragment, assuming that the array dataValues has been initialized to contain the sequence: 2, 4, 6, 8, 10? for (int d: dataValues) { d = d * 2; } System.out.println("The first value is: " + dataValues[0]); Question 14 options: A) bounds error B) 4 C) 8 D) 2 Save Previous PageNext Page

D

What is the output? int x = 789; if(x>700) out.println("big"); else out.println("little"); Question 82 options: A) 0 B) little C) 700 D) big Save Previous PageNext Page

D

Which method call represents the invocation of a method that does not have explicit parameters? Question 50 options: greeting.replace("Hello", "Welcome"); greeting.length greeting.length() System.out.println(greeting);

Greeting.length( )

Consider the following code segment shown below. int x = 0; while ( /* missing code */ ) { x = x + 5; System.out.print(x + ""); } Listed below are possible replacements for /* missing code */. I. x < 20 II. x < 25 III. x <= 25 Which of the proposed replacements for /* missing code */ will cause the code segment to print only the values 5 10 15 20 25? Question 106 options: a) I and III only b) II only c) II and III only d) I only e) III only

II only

Consider the following instance variables and methods that appear in a class representing robot information. private int turnsMade; private double averageSpeed; public boolean willCrash() { /* code */ } A robot will crash if at least one of the following conditions is met. The robot has an average speed greater than 110. The robot has an average speed greater than 80 and has made at least 7 turns. Consider the following proposed implementations of the willCrash method. I. if ( averageSpeed > 110 ) return true; return false; II. if ( averageSpeed > 110 ) return true; if ( averageSpeed > 80 ) return true; if ( turnsMade > 7 ) return true; return false; III. if ( averageSpeed > 110 ) return true; if ( averageSpeed >80 ) if( turnsMade >=7 ) return true; return false; Which of the proposed implementations will correctly implement method willCrash ? Question 96 options: I only II only III only I, II, and III I and III only

III only

What does an object store its data in? Question 69 options: files methods instance variables access specifiers Save Previous PageNext Page

Instance variables

What is the array type? int [] temps = new int [3];

Int

Which statement declares a variable that references an array of integers? Question 3 options: A) integer() intData = new integer(6); B) integer[] intData = new integer[6]; C) int[] intData = new int[6]; D) int() intData = new int(6);

Int [ ] intData = new int [ 6 ]

Which statement correctly determines the number of characters in the string referenced by variable myString? Question 46 options: int n = myString.size; int n = myString.size(); int n = myString.length; int n = myString.length();

Int n = myString.length ( );

What is the type of a variable that references an array of integers? Question 2 options: A) int() B) integer() C) integer[] D) int[]

Int[ ]

Consider the following valid code fragment: String partOfString = input.substring(first,last); What is the length of partOfString? Question 47 options: last - first + 1 first - last + 1 last - first first - last Save Previous PageNext Page

Last - first

An uninitialized, undefined, empty, or meaningless value. Question 18 options: null void error empty Save Previous PageNext Page

Null

A numeric computation ___________ if the result falls outside the range for the number type. Question 51 options: overflows concatenates truncates rounds

Overflows

The input to a method is called a(n) _______________. Question 68 options: overloaded parameter interface procedure Save Previous PageNext Page

Parameter

You should declare all instance variables as ___. Question 35 options: protected class public private

Private

Which of the following represents a method declaration with a void return type? Question 64 options: public void setValue(int value) { ... }; public void int getValue() { ... }; void public setValue(int value) { ... }; void int getValue() { ... }; Save Previous PageNext Page

Public void setValue (int value). { .....};

What statement is used to specify the value that a method gives back to its caller? Question 36 options: new public private return Save Previous PageNext Page

Return

Based on the code below, which statement creates a string in the format "Hello, NAME!"? String hello = "Hello"; String name; // Assume value is initialized by the program Question 74 options: String helloName = hello + ", " + name + "!"; String helloName = hello + name + "!"; String helloName = hello + ", " + name; String helloName = hello + name; Save Previous PageNext Page

String helloName = hello + ", " + name + "!";

Which of the following declares a variable that will store a welcome message? Question 76 options: int welcome; double welcome; Char welcome; String welcome;

String welcome

String mascot = "I like Eagles"; Using charAt, which line of code will print the last character of mascot? Question 45 options: System.out.println( mascot.charAt(11) ); System.out.println( mascot.charAt(12) ); System.out.println( mascot.charAt(13) ); System.out.println( mascot.charAt(14) ); None of these

System.out.println( mascot.charAt(12) );

String mascot = "I like Eagles"; Using the one paramater form of substring, which line of code will print the last character of mascot? Question 44 options: None of these System.out.println( mascot.substring(13) ); System.out.println( mascot.substring(12, 14) ); System.out.println( mascot.substring(11) ); System.out.println( mascot.substring(12) );

System.out.println( mascot.substring(12) );

Assume s is a String. Using the two-parameter form of substring, which line of code will print the last character of s? Question 40 options: None of these System.out.println( s.substring( s.length( ) - 1, s.length ) ); System.out.println( s.substring( s.length( ) - 1, s.length( ) ) ); System.out.println( s.substring( s.length( ) + 1, s.length( ) ) ); System.out.println( s.substring( s.length( ), s.length( ) ) );

System.out.println( s.substring( s.lengtg( ) - 1, s.length( ) ) );

Assume s is a String. Using the one-parameter form of substring, which line of code will print the last character of s? Question 41 options: System.out.println( s.substring(s.length - 1 ) ); System.out.println( s.substring(s.length( ) - 1 ) ); System.out.println( s.substring(s.length( ) ) ); System.out.println( s.substring(s.length( ) + 1 ) ); None of these

System.out.println( s.substring(s.length( ) - 1 ) );

What is the name of the reference variable? int [] temps = new int [3];

Temps

Which of the following statements about test (runner/driver) programs is true? Question 65 options: Test (runner/driver) programs verify that methods have been implemented correctly. A tester (runner/driver) class does not contain the main method. You do not have to display the expected results. Writing test (runner/driver) programs is not an important skill.

Test (runner/driver) programs verify that methods have been implemented correctly

Consider this code fragment. int dollars = 10; double balance = dollars; Which of the following statements is true? Question 52 options: The code compiles but it sets dollars to 10.0. The code compiles but it sets balance to a wrong value due to a rounding error. The code does not compile. The code compiles and runs correctly. Save Previous PageNext Page

The code complies and runs correctly

Consider this code fragment. System.out.println("The account balance is: " + acct.getBalance()); Which of the following statements is true? Question 72 options: The code does not compile because you cannot add a string and a number. The code compiles but it generates an exception at run-time. The code compiles and runs but it does not display the balance of the account. The code compiles and runs correctly, displaying the label and balance of the account.

The code complies and runs correctly, displaying the label and balance of the account

Which of the following statements about methods is correct? Question 63 options: A method can have only one explicit parameter. The return value of a method can be used as a parameter. Every method must have a return value. A method can have multiple implicit parameters. Save Previous PageNext Page

The return value of a method can be used as a parameter

What is the purpose of the assignment operator? Question 67 options: to check for inequality to check for identity to check for equality to change the value of a variable Save Previous PageNext Page

To change the value of a variable

What is printed by the following? String p = "ABCDE"; System.out.println("X" + p.substring(2,2) + "X"); Question 42 options: XCX XX XBX Illegal, won't compile None of these Save Previous PageNext Page

XX

Arrays are enclosed by ____. Question 23 options:

[ ], [ ]

Conditions are enclosed by _____________? Question 119 options: A) ( ) B) [ ] C) < > D) { }

a

If an analog signal picks up some noise, has information been lost? Question 142 options: A) Yes—the noise hides the exact values of the original signal. B) No—information has been added to the signal. C) Maybe—it depends on how loud the noise is. D) No—electronics can just ignore the noise.

a

What is a bit? Question 147 options: A) A single on/off value. B) Enough memory to store a character. C) A large section of computer memory. D) A value of "one."

a

What is a computer network? Question 137 options: A) Two or more computers connected together to exchange data and programs. B) A group of computers that share the same power supply. C) A computer that can run many programs from its hard disk. D) A computer that is used by many different human users. Save Previous PageNext Page

a

What is a source program? Question 158 options: A) A text file created by a programmer containing instructions written in a high level language. B) The program that the processor is executing a particular instant. C) The first copy ever made of a program. D) A collection of machine instructions that the processor can execute.

a

What is an interpreter? Question 160 options: A) An interpreter is a program that acts like a processor that can directly execute a high level language. B) An interpreter translates executable programs between Apple computers and Intel computers. C) An interpreter takes an executable program as input and creates a source program. D) An interpreter acts as a messenger between main memory and secondary memory.

a

What is an operating system? Question 135 options: A) Systems software that coordinates the hardware and software components of a computer system. B) The part of the hardware that operates the mouse and the windows on the monitor. C) A section of software that must be part of every program. D) The part of the hardware that operates input and output devices.

a

What is output by the code below? int j=1, tally=0; while(j<8) { tally++; j++; } out.print(tally); Question 110 options: a) 7 b) 10 c) 8 d) 6 e) 9 Save Previous PageNext Page

a

What is the following code attempting to calculate? public static int go( int x, int y) { int cnt = 0; for(int n = x; n < y; n = n + 1) if(n % 2 == 0 ) cnt++; return cnt; } Question 111 options: a) The code is counting the number of even numbers between x and y. b) The code is counting the number of odd numbers between x and y. c) The code is counting the number of negative numbers between x and y. d) The code is counting the number of positive numbers between x and y. e) The code is counting the number of prime numbers between x and y. Save Previous PageNext Page

a

What is true of an analog signal? Question 141 options: A) An analog signal is usually continuously changing in value. B) An analog signal can never be converted into a binary signal. C) An analog signal is the only way that music can be recorded. D) An analog signal has a discrete number of states

a

What part of a computer system is most directly concerned with performing the actions called for by a program? Question 157 options: A) The processor. B) The main storage. C) The monitor. D) The hard disk. Save Previous PageNext Page

a

Which of the following loops will print out the numbers 3, 5, 7, 9, 11? I. int i=1; while(i<10) { i=i+2; out.println(i); } II. int i=3; while(i<=11) { out.println(i); i=i+2; } III. for(int i=4;i<=12;i=i+2) { out.println(i-1); } Question 114 options: a) I, II, and III b) II only c) I only d) I and III only e) II and III only Save Previous PageNext Page

a

Which component does the actual computation of a computer system? Question 130 options: A) The power supply. B) The main memory. C) The processor chip. D) The secondary memory.

c

Which of the following is NOT an advantage of building computers out of binary devices? Question 140 options: A) Patterns of bits can be used to represent anything symbolic. B) Binary signals are unambiguous. C) Binary devices are much faster than decimal devices. D) Binary devices are simple and easy to build.

c

A(n) _______________ is a sequence of values of the same type. Question 1 options: A) run B) array list C) array D) sequence

array

How many iterations does the following for loop execute? for(x = 0; x < 100; x += 5) ... Question 122 options: A) 19 B) 20 C) 21 D) 0

b

The 8-bit binary number 1100 1110 is equal to which decimal value? Question 136 options: A) 127 B) 206 C) 66 D) 12

b

What are the two general types of programs? Question 134 options: A) Microsoft and IBM. B) Entertainment and Productivity. C) Word processors and Databases. D) System software and Application software.

b

What does the word binary mean? Question 138 options: A) Binary means "having a discrete number of values." B) Binary means "having only two states." C) Binary means "containing a computer." D) Binary means "using electronics to do arithmetic."

b

What is 25 * 23 ? Question 151 options: A) 106 B) 28 C) 48 D) 210 Save Previous PageNext Page

b

What is ASCII? Question 152 options: A) American Storage Computer for Input Information B) American Standard Code for Information Interchange C) All Storage Computer Informational Image D) Alpha Standard Coding Informational Input

b

What is output by the code below? int d=5; if(d>3 || d<0) System.out.print("fun"); else System.out.print("go"); Question 117 options: a) go b) fun c) fungo d) gofun e) there is no output Save Previous PageNext Page

b

What is the difference between hardware and software? Question 128 options: A) Hardware is permanent, software is temporary. B) Hardware is tangible, but software is intangible. C) Hardware is metal, software is plastic. D) Hardware is reliable, software is unreliable. Save Previous PageNext Page

b

Which is considered to be the computers short-term memory? Question 155 options: A) REM B) RAM C) RIM D) ROM

b

Which one of the following statements is FALSE? Question 148 options: A) A bit may be implemented as a small part of a magnetic disk. B) A bit is always implemented as something electrical. C) Copying a bit from one medium to another does not affect the information it represents. D) The method used to implement a bit does not affect the information it represents. Save Previous PageNext Page

b

Why does a computer have a clock? Question 144 options: A) A clock is used only with application programs that need to know the current time. B) The state of binary signals is measured only at specific instants in time. C) A clock is needed to check that voltage levels are correct. D) A clock is needed to check how fast signals are changing.

b

Which of the following statements is equivalent to balance = balance + amount; ? Question 57 options: balance += amount; balance == amount; balance +== amount; balance =+ amount;

balance += amount;

Assume that a game has four doors and the only way to win the game is to successfully find all four doors. If the player finds all four doors, the method should return true. If all four doors are not the found, the game should return false. Each time a door is found, a variable for that door is set to true. Which of the following code segments could be placed in the method to properly check for the doors and return the appropriate values? I. if(doorOne || doorTwo || doorThree || doorFour ) return true; return false; II. if(doorOne && doorTwo && doorThree && doorFour ) return true; return false; III. if(!doorOne) return false; if(!doorTwo) return false; if(!doorThree) return false; if(!doorFour) return false; return true; Question 118 options: a) III only b) I and II only c) II and III only d) I only e) II only Save Previous PageNext Page

c

Can Japanese writing be represented in a computer? Question 145 options: A) No — only English can be represented. B) No — only languages with an alphabet can be represented. C) Yes — since it is symbolic, and anything symbolic can be represented. D) Yes — but a special processor chip is needed.

c

How many iterations does the following for loop execute? for (x = 1; x <= 50; x = x * 2) . . . Question 121 options: A) 7 B) 4 C) 6 D) 5

c

How much memory is in one megabyte? Question 150 options: A) About 1000 bytes. B) About one billion bytes. C) About one million bytes. D) About 100 bytes. Save Previous PageNext Page

c

The decimal number 188 is represented by which binary number? Question 143 options: A) 1111 1000 B) 1100 0011 C) 1011 1100 D) 0111 1000 Save Previous PageNext Page

c

What is an embedded system? Question 133 options: A) A program that comes shrink-wrapped in a box. B) A program that is permanently part of a computer. C) A computer and software system that controls a machine or appliance. D) A computer that is part of a larger computer.

c

When the body of a loop contains another loop, the loops are __________. Question 123 options: A) symmetric B) spaghetti code C) nested D) asymmetric Save Previous PageNext Page

c

Where are programs and data kept while the processor is using them? Question 132 options: A) Disk memory. B) Program memory. C) Main memory. D) The secondary memory.

c

Which of the following loops will print out the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10? I. for(int i=1;i<=10;i++) { out.println(i); } II. int i=0; while(i<10){ out.println(i); i++; } III. int i=0; while(i<10) { i++; out.println(i); } Question 113 options: a) II and III only b) I and II only c) I and III only d) I only e) II only Save Previous PageNext Page

c

Which type has the two values: true and false? Question 120 options: A) enumerated B) predicate C) boolean D) flag Save Previous PageNext Page

c

Which of the following gets the last character of the string referenced by sentence? Question 75 options: char ch = sentence.charAt(sentence.length()-1); Char ch = sentence.charAt(length()); char ch = sentence.charAt(sentence.length()); Char ch = sentence.charAt(length()-1); Save Previous PageNext Page

char ch = sentence.charAt (sentence.length ( ) -1);

Can English writing be represented with analog signals? Question 146 options: A) No—only binary signals can represent symbolic data. B) No—it is not symbolic. C) No—analog signals don't represent anything. D) Yes—just read out loud into a microphone.

d

What are the two fundamental things the processor can do to a byte of main memory? Question 153 options: A) It can write the byte to secondary storage and it can read the byte from secondary storage. B) It can add the value from main memory to a sum, and it can print the value on the monitor. C) It can erase a byte in main memory, and it can read a byte of main memory. D) It can write 8 bits to a byte in memory, and it can read 8 bits from a byte in memory.

d

What does a computer language compiler do? Question 159 options: A) It takes an executable program as input and runs it on the computer. B) It takes the output of a program and displays it on the computer monitor. C) It translates a program in main memory into a program on secondary memory. D) It takes a source file as input and produces an executable program as output.

d

What hardware components (of a typical desktop computer) are usually found inside of the case? Question 129 options: A) The keyboard, the disks, and the audio blaster. B) First, second, and third memory. C) The processor, main memory, and monitor. D) The processor, main memory, and secondary memory

d

What is a bit? Question 139 options: A) A bit is a small unit of computer time. B) A bit is a single character stored in main memory. C) A bit is a collection of several bytes. D) A bit is a single binary value.

d

What is a file? Question 154 options: A) A file is the part of a program that is used to describe what the program should do. B) A file is another name for a hard disk. C) A file is a section of main storage used to store data. D) A file is a collection of information that has been given a name and is stored in secondary memory.

d

What is a group of 8 bits usually called? Question 149 options: A) A bight. B) A blight. C) A bite. D) A byte.

d

What is output by the code below? int b=5; if(b>3 && b>10) System.out.print("fun"); System.out.print("go"); Question 116 options: a) gofun b) funfun c) fungo d) go e) fun Save Previous PageNext Page

d

What is returned by the call what(227) ? public boolean what(int num) { boolean check = true; for(int i = 2; i < Math.sqrt(num); i++) { if(num % i == 0) return false; } return true; } Question 112 options: a) 1 b) -1 c) false d) true e) 0 Save Previous PageNext Page

d

What is the following code attempting to calculate? public static int go( int x ) { int ans = 0; while( x > 0 ) { ans += 1; x /= 10; } return ans; } Question 115 options: a) The code is counting the number of 0s in the number. b) The code is summing all of the digits in the number. c) The code is counting the number of times you can substract 10 before reaching 0. d) The code is counting the number of digits in the number. e) The code is counting the number of 1s in the number.

d

What is the role of the operating system in managing files? Question 156 options: A) The operating system is not involved with files; it just keeps the hardware running. B) The operating system is only concerned with the files it needs for itself. C) The operating system will access files that contain application programs and start the application running, but the applications totally manage their own files. D) Everything done to or with files on a computer system involves the operating system.

d

Which type of memory is most closely connected to the processor? Question 131 options: A) Disk memory. B) Tape memory. C) The secondary memory. D) Main memory. Save Previous PageNext Page

d

What is output by the code below? int w=100, x=88; if(w>90) if(x>80) out.print("def"); else out.print("xyz"); else out.print("ghi"); out.print("fun"); Question 102 options: xyzdef xyzfun xyz deffun ghifun

def fun

Which of the following code fragments will compile without error? Question 70 options: double balance = 13.75;; int dollars = (int) balance; double balance = 13.75; int dollars = balance; (int) balance = 13.75 int balance = (double) 100;

double balance = 13.75;; int dollars = ( int) balance;

Which of the following statements corresponds to computing the line item total on an invoice given the quantity and price of the item? Question 58 options: int lineItemTotal = (int) quantity * price; double lineItemTotal = qty * price; double lineItemTotal = quantity * price; int lineItemTotal = quantity * price;

double lineItemTotal = quantity * price;

Which of the following declares a variable that will store a measurement with fractional parts? Question 61 options: int measure; double measure; String measure; integer measure;

double measure;

Which statement correctly computes a specified number raised to the specified power? Question 33 options: double p = 2.pow(3); double p = Math.pow(2,3); double p = 2.power(3); double p = Math.power(2,3);

double p = Math.pow (2,3) ;

Which statement correctly computes the square root of the given number? Question 56 options: int s = Math.sqrt(16); int s = Math.squareroot(16); double s = Math.sqrt(16); double s = Math.squareroot(16);

double s = Math.sqrt(16);

What is output by the code below? for(int h=1; h<6; h++) System.out.print( h ); Question 109 options: a) 12 b) 123 c) 1234 d) 4321 e) 12345

e

What returned by the call check("abc","abc") ? public static String check(String a, String b) { if(a.compareTo(b) > 0) return "bigger"; if(a.compareTo(b) < 0) return &quot;smaller&quot;; return &quot;equal&quot;; } Question 90 options: equal bigger 0 -1 smaller Save Previous PageNext Page

equal

What is output by the code below? int numK = 101; switch(numK) { case 11 : out.print("one"); break; case 21 : out.print("two"); case 98 : out.print("three"); break; case 101 : out.print("four"); case 111 : out.print("five"); break; case 121 : out.print("six"); } Question 97 options: twothree fourfive two twothreefour fourfivesix

fourfive

What is output by the code below? int numP = 100, numQ = 84; if(numP > 90) if(numQ > 90) out.print("def"); else if(numQ > 85) out.print("xyz"); else if(numQ > 80) out.print("ghi"); out.print("fun"); Question 94 options: ghi fun ghifun deffun def

ghifun

What is output by the code below? int b = 350; if(b < 700) out.println("go"); else out.println("stop"); Question 86 options: stop 789 700 0 go Save Previous PageNext Page

go

Which of the following declares a variable that will store a count with an integer value? Question 62 options: integer count; double count; String count; int count;

int count;

int e=3; if(e >= 5) out.print("same"); else out.print("notsame"); out.print("done"); Question 99 options: same samedone notsame done notsamedone

notsamedone

Which of the following corresponds to a valid constructor header for the Player class? Question 38 options: public Player() private Player() public void Player() private void Player()

public Player ( )

What statement is used to specify the value that a method gives back to its caller? Question 71 options: new public private return

return

What returned by the call check("ABC","abc') ? public static String check(String a, String b) { if(a.compareTo(b) > 0) return "bigger"; if(a.compareTo(b) < 0) return "smaller"; return "equal"; } Question 89 options: 0 -1 equal smaller bigger Save Previous PageNext Page

smaller

What returned by the call check("cat","dog") ? public static String check(String a, String b) { if( a.charAt(0) > b.charAt(0)) return "bigger"; if( a.charAt(0) < b.charAt(0) ) return "smaller"; return "equal"; } Question 91 options: bigger 0 equal -1 smaller

smaller

Which of the following statements corresponds to revising an invoice subtotal with a line item given the quantity and price of the item? Question 59 options: subtotal = subtotal + (quantity * price); subtotal =+ quantity * price; subtotal = (subtotal + quantity) * price; subtotal =+ (quantity * price); Save Previous PageNext Page

subtotal = subtotal + (quantity * price);

What is the output? int a = 3; int b = 7; if(a>5 && b>5) out.println("both are >5"); out.println("testing");

testing


Related study sets

WWII Battles Study Guide: European Theatre

View Set

Government and politics - Federalism

View Set

SCM 303- Chapter 3 HW, Exams 1-3, Exam 4 SCM 303, Exam 3, Chapter 11 (Johnson 2), Chapter 10- Johnson 1, Chapter 7 (inventory) HW, Coursepack Chapter 6 HW(Johnson CH.7), SCM Intro & Chapter 08 Section 05 and 05, SCM Chapter 9 HW(Swink CH.8), SCM HW5,...

View Set

Knewton Alta Chapter 2 Descriptive statistics - part 3

View Set

Week 6- Information Security and Privacy

View Set

Scientific Methods assignment and quiz

View Set

WK10/MN success/High Risk Antepartum

View Set