APCSA - Review Questions Unit 28 - 30 1/2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Consider the following code: String word [] = {"algorithm", "boolean", "char", "double"}; for ( int i =0; i < word.length/2; i++) { String temp = word[i]; word[i] = word[word.length - 1 - i]; word[word.length - 1 - i] = temp; } What would happen if you did the following instead? for ( int i =0; i < word.length/2; i++) { word[i] = word[word.length - 1 - i]; word[word.length - 1 - i] = word[i]; } A. The last two values are copied into positions 0 and 1 so you get: double char char double. B. It would work as intended. C. There would be an out of bounds error. D. The last value would be copied into the entire array so you would get: double double double double E. The first value would be copied into the entire array so you would get: algorithm algorithm algorithm algorithm

A

Consider the following code: String words[] = {"BEAUTIFY", "BENEVOLENCE", "BENIGN", "BEQUEST", "BERATE","BEREFT", "BEWILDER"}; for (int i=0; i< words.length; i++) { System.out.print(words[i].charAt (words[i].length()/2)); } What is output? A. TOIUAEL B. ILGETFD C. UVNQRRI

A

What is 0 0 1 0 0 1 0 in base ten? A. 18 B. 2 C. 16 D. 17 E. 20

A

What is 73 in binary? Be sure to write your answer in 8 bit form. A. 01001001 B. 01001011 C. 01011011 D. 01011001

A

What is 86 in binary? Be sure to write your answer in 8 bit form. A. 01010110 B. 01010111 C. 01010100 D. 01011110

A

What is 00101001 in base ten? A. 39 B. 42 C. 40 D. 41

D

What is 00111111 in base ten? A. 62 B. 65 C. 61 D. 63

D

The following code is intended to count how many "hard" spelling words are assigned in a week. A hard spelling word is defined as having more than 5 letters. Consider the following code: String list [] = /* initialized to the spelling words */; int hard = 0; for (int i = 0; i < list.length; i++) { if ( /* missing code */ ) hard++; } System.out.println("Hard words: " + hard); Which could be used to replace /* missing code */ so that it works as intended? A. list[i] > 5 B. list[i].length > 5 C. list.length[i] > 5 D. list[i].length() > 5 E. list.length > 5

D

When creating an array of Strings, the elements are: A. null B. ints C. None of the items listed. D. Strings E. References to the memory address where each String is stored.

E

Consider the following code: String words[] = {"BEAUTIFY", "BENEVOLENCE", "BENIGN", "BEQUEST", "BERATE", "BEREFT", "BEWILDER"}; int s = 0; for (int i=0; i < words.length; i++) { if ( words[s].length() < words[i].length() ) s = i; } System.out.println(words[s]); What is output? A. BEAUTIFY B. BENEVOLENCE C. BEREFT D. BEWILDER

B

Consider the following code: String words[] = {"BEAUTIFY", "BENEVOLENCE", "BENIGN", "BEQUEST", "BERATED", "BEREFT", "BEWILDER"}; int s = words.length -1; for (int i=0; i < words.length; i++) { if ( words[s].length() > words[i].length() ) s = i; } System.out.println(words[s]); What is output? A. BEREFT B. BENIGN C. BENEVOLENCE D. BERATED

B

What is 1 1 0 1 0 1 0 in base ten? A. 104 B. 106 C. 102 D. 100 E. 105

B

What is 43 in binary? Be sure to write your answer in 8 bit form. A. 00101111 B. 00101011 C. 00101001 D. 00101010

B

What is 55 in binary? A. 0 0 1 1 0 1 1 0 B. 0 0 1 1 0 1 1 1 C. 0 0 1 1 0 1 0 0 D. 0 0 1 1 0 0 1 1 E. 0 0 1 1 0 1 0 1

B

When coding with an array you most often need to use a(n) ______. A. Else Statement B. For Loop C. While Loop D. None of the items listed. E. If Statement

B

A student is having trouble remembering how to spell words that end in -ing. She needs a program to count how many ing words she has each week in her spelling list. Consider the following code: String list [] = /* initialized to the spelling words */; int ing = 0; for (int i = 0; i < list.length; i++) { System.out.println(i + " " + ing); if (list[i].length() > 3) if ( /* missing code */ ) ing++; } System.out.println("Number of ing words: " + ing); Which of the following could be used to replace /* missing code */ so that this works as intended? A. list[i].substring(4, 7 ).equals("ing") B. list[i].equals("ing") C. list[i].substring(list[i].length() - 3, list[i].length() ).equals("ing") D. list[i].substring(list[i].length() - 3, 3).equals("ing") E. list.substring(list.length() - 3, list.length() ).equals("ing")

C

Consider the following code: String word [] = {"algorithm", "boolean", "char", "double"}; for ( int i =0; i < word.length/2; i++) { word[i] = word[word.length - 1 - i]; } What is stored in word after running this code? A. algorithm boolean char double B. double char boolean algorithm C. double char char double D. algorithm boolean boolean algorithm E. algorithm algorithm algorithm algorithm

C

Consider the following code: String words[] = {"BEAUTIFY", "BENEVOLENCE", "BENIGN", "BEQUEST", "BERATE","BEREFT", "BEWILDER"}; for (int i=0; i< words.length; i++) { if (words[i].substring(0, 3).compareTo ("BEN") != 0 ) System.out.println(words[i]); } What is output? A. None of the items listed. B. BENEVOLENCE BENIGN BERATE BEREFT BEWILDER C. BEAUTIFY BEQUEST BERATE BEREFT BEWILDER D. BEWILDER BEATIFY BEQUEST BERATE BEREFT E. BEQUEST BERATE BEREFT BEWILDER BEAUTIFY

C

Which of the following is the correct way to find the length of the String in the first element of an array called words? A. words.length()[0] B. words[0].length C. words[0].length() D. words.length E. words.length[0]

C

What is 01100101 in base ten? A. 99 B. 105 C. 103 D. 101

D

What is 21 in binary? A. 0 0 1 0 1 0 0 B. 0 0 1 0 0 1 1 C. 0 0 1 0 1 1 0 D. 0 0 1 0 1 0 1 E. 0 0 1 0 1 1 1

D

What is output by the following? String w[] = {"zebra"}; System.out.println(w[0].charAt(w.length -1)); A. Prints the second to last character in the String B. Nothing, there is an index out of bounds error. C. Prints the last character in the String D. None of the items listed. E. Prints the first character in the String

E

When a program needs to ask a question to choose between several options you most often need to use a(n) ______. A. For Loop B. None of the items listed. C. Else Statement D. While Loop E. If Statement

E


संबंधित स्टडी सेट्स

Chapter 1: The Science and Scope of Nutrition, Nutrition Chapter 1- Science of Nutrition, Ch. 1 Summertime Quiz

View Set

Unit 2 Review Flashcards + I Used To Think Concepts

View Set

Astronomy Semester 2 Module 6: The Future of Space Travel

View Set

Chapter 39 nursing care of the adult

View Set

Arrangement of the Periodic Table

View Set

Chapter 7 History of R & R - What's That Sound?

View Set