Final study

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

In Ms. Garcia's computer science class, students receive letter grades based on the following scale. Integer Score Letter Grade 92 or above A From 81 to 91 (inclusive) B From 72 to 80 (inclusive) C 71 or below F Which of the following code segments will assign the correct string grade for a given integer score?

I and III only

Melissa will only drink a cup of coffee if she has slept less than 8 hours or she had to wake up before 6 am. In which of the following cases does Melissa not drink a cup of coffee? a. Melissa sleeps for 8 hours and wakes up at 7 am b. Melissa sleeps for 7 hours and wakes up at 8 am c. Melissa sleeps for 9 hours and wakes up at 5:30 am d. Melissa sleeps for 7 hours and wakes up at 6 am

a

You're building an e-commerce website. You create a class called Transaction to represent a single purchase on the site. Which of these would not make sense as an instance variable in the Transaction class? a. private int totalTransactionsToday b. private double price c. private String purchaserEmail d. private String productName

a

What value will be help in mysteryNumber when this code finishes running? int mysteryNumber = 0; String[] mysteryArray = {"Finn", "Jake", "Bubblegum"}; for(int i = 0; i < mysteryArray.length; i++) { mysteryNumber += mysteryArray[i].length(); } a. 17 b. 0 c. 1 d. 16

a.

What for loop will properly print "good luck" 10 times? a. for(int i = 10) { System.out.print("good luck"); } b. for(int i = 0; i < 10; i++) { System.out.println("good luck"); } c. for(int i = 0; i++; i < 10) { System.out.println("good luck"); } d. for(int i = 10; i < 0; i++) { System.out.println("good luck"); }

b

What is the output of the following program? public class Main { private String str = "dog"; /*Use public static void main() to replace the line below outside of the CodeHS platform.*/ public void run() { Main m = new Main("cat"); System.out.println(m.getString()); } public Main(String str) { str = str; } public String getString() { return str; } } a. The program does not compile. b. dog c. The program does not produce any output d. cat

b.

What are parameters?

The formal names given to the data that gets passed into a method.

Consider the following program code: int x = 5; int y = 8; int temp = x; x = y; y = temp; What are the values of x and y as a result of this program code? a.x has a value of y y has a value of temp b.x has a value of 5 y has a value of 8 c.x has a value of 8 y has a value of 5 d. x and y have a value of 5

c

Given this array: 1 2 4 5 6 7 8 12 14 21 22 42 53 How many comparisons are required to find 42 using the Binary Search? a. 2 b. 10 c. 3 d. 5

c

What does this method call return? public int doubleInt(int x) { x * 2; } a. 10 b. 5 c. This method is improperly written d. This method returns nothing

c.

Karel the Dog is instructed to move forward two spaces. Then, if Karel is standing on a ball, Karel will turn left and move forward two spaces. Otherwise, Karel will move forward two spaces. Given the starting point below, where will Karel end up?

choose the one with the dog facing up

Evaluate the mathematical expression: 18 ÷ 3 + 3 × 3 - 8 a. 2 b. 4 c. 5 d. 7

d

If x represents the area of the number line colored blue, which inequality accurately reflects the value of x? a. x < 8 b. x > 8 c. x >= 8 d. x =< 8

d

What does this program output? Shape shape1 = new Shape(); Shape shape2 = new Rectangle(); Shape shape3 = new Square(); Shape shape4 = new Circle(); System.out.println(shape1.getShapeName()); System.out.println(shape2.getShapeName()); System.out.println(shape3.getShapeName()); System.out.println(shape4.getShapeName()); a. Shape Rectangle Rectangle Oval b.Shape Rectangle Square Circle c. This code will error d. Shape Rectangle Rectangle Circle

d.

Which of the following are valid arrays? I. int[] coolArray = {1, 2, 3}; II. int[] threeThings = {1.0, 2.0, 3.0}; III. int[] = {"1", "2", "3"}; a. II only b. III only c. I and II only d. I only e. I and III

d.


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

Human Geography- Pakistan & Bangladesh

View Set

Ch. 7. Single-Dimensional Arrays

View Set

AP Biology: Unit 2 Topic Questions Formative Assessment Part 1

View Set

Police Administration - Chapter 12

View Set

Prins. of Development Final Exam

View Set