code hs sem 1 final practice

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

What is printed by the following program? function printNumbers(two, one, zero){ println(two); println(one); println(zero); } function start(){ var zero = 0; var one = 1; var two = 2; printNumbers(zero, one, two); }

0 , 1 ,2

What is the output of the following program? var result = 0; var max = 5; for(var i = 0; i < max; i++){ result += i; } println(result);

10

The decimal value 1010 The binary value 100 Hexadecimal value C Which of the following lists the number in order from least to greatest?

1001, 10, C

What is the decimal value of 1101

13

What is the output of the following program? function start(){ var x = 5; sumTo(x); println(x); } function sumTo(num){ var sum = 0; for(var i = 0; i <= num; i++){ sum += i; } println(sum); }

15,5

How many different digits are used in the Hexadecimal number system?

16

An online store uses 8-bit binary values to identify each unique item for sale. The store plans to increase number of items it sells and is considering changing to 9-bit binary values. Which of the following best describes the result of using 9-bit values instead of 8-bit values?

2 times as many items can be uniquely identified

What is the last thing printed by the following program? var start = 30; var stop = 10; for(var i = start; i >= stop; i-=5){ if(i % 2 == 0){ println(i * 2); } else { println(i); } }

20

Suppose the ESPN website uses 8-bit unsigned integers to store how many points a team has scored in an NBA game.

255

An IPv4 address has 32 bits, so there are 232 (over 4 billion) possible IPv4 addresses. Since the Internet is gaining devices quickly, we will soon surpass 232 unique devices on the Internet. In anticipation of all the new Internet devices, we are in the process of switching to IPv6, which uses 128 bits for a single address. That's 96 extra bits to represent one address! Which of the following statements correctly describes how many more addresses will be possible to represent by switching from IPv4 to IPv6?

296 times as many addresses can be represented with IPv6

A news website uses 32-bit integers to count the number of times an article has been viewed. The website is becoming more popular, and expects some of the articles to exceed the number of views that can be represented with 32 bits. In anticipation of this, the website is planning to change to 64-bit integers for the view counter. Which of the following best describes the result of using 64-bit integers instead of 32-bit integers?

2^32 times as many values can be represented

The following code continually asks the user for a password until they guess the correct password, then ends. But there is one problem. 1 var SECRET_PASSWORD = "karel"; 2 3 function start(){ 4 while(true){ 5 var password = readLine("Enter your password: "); 6 if(password == SECRET_PASSWORD){ 7 println("You got it!"); 8 } 9 println("Incorrect password, please try again."); 10 } 11 } Which of the following will fix this program?

Add a break; statement after line 7 so that the program doesn't loop infinitely

Which of the following best explains what happens when a new device is connected to the Internet?

An Internet Protocol (IP) address is assigned to the device.

What is a Distributed Denial of Service (DDoS) attack?

An attempt to deny access to a website by flooding the website's servers with millions of requests from different computers

Which of the following is LEAST likely to indicate a phishing attack?

An email from your bank asks you to call the number on your card to verify a transaction.

Which number system is used to store information digitally in a computer?

Binary (base 2)

What is printed by the following program? var numApples = 10; var numOranges = 5; if(numApples < 20 || numOranges == numApples){ println("Hello, we are open!"); } else { println("Sorry, we are closed!"); } println("Sincerely, the grocery store");

Hello, we are open! Sincerely, the grocery store

Which of the following are true statements about digital certificates in Web browsers? I. Digital certificates are used to verify the ownership of encrypted keys used in secure communication. II. Digital certificates are used to verify that the connection to a Web site is fault tolerant.

I only

What is printed by the following program? var isRaining = false; var isCloudy = false; var isSunny = !isRaining && !isCloudy; var isSummer = false; var isWarm = isSunny || isSummer; println("Is it warm: " + isWarm);

Is it warm: true

Why do we write functions?

Make our code easier to understand by giving a readable name to a group of instructions Avoid writing repeated code Make our code reusable

Which of the following activities poses the greatest personal cybersecurity risk?

Purchasing a couch by emailing a credit card number to the couch owner

A city government is attempting to reduce the digital divide between groups with differing access to computing and the Internet. Which of the following actions is LEAST likely to be effective in this purpose?

Putting helpful tips for operating computers on the city government website

Which of the following is a benefit of the fault-tolerant nature of Internet routing?

The ability to provide data transmission even when some connections between routers have failed

Two computers are built by different manufacturers. One is running a Web server and the other is running a Web browser. Which of the following best describes whether these two computers can communicate with each other across the Internet?

The computers can communicate directly because Internet communication uses standard protocols that are used by all computers on the Internet.

A user enters a Web address in a browser, and a request for a file is sent to a Web server. Which of the following best describes how the file is sent back to the user?

The file is broken into packets and sent over a network. The packets must be reassembled by the user's computer when they are received. If any packets are missing, the browser re-requests the missing packets.

var RED = 0; var GREEN = 1; var BLUE = 2; function filter(pixel) { pixel[RED] = 255 - pixel[RED]; pixel[GREEN] = 255 - pixel[GREEN]; pixel[BLUE] = 255 - pixel[BLUE]; return pixel; } Which of the following best describes the result of applying this filter to every pixel in the image?

The image will be inverted, bright pixels will become dark and dark pixels will become bright.

A student is transferring photos from her camera to her computer. The student notices that the saved photos on her computer are lower quality than the original raw photo on her camera. Which of the following could be a possible explanation for the difference in image quality

The saved image files were compressed with a lossy compression technique.

Which of the following would pose the greatest threat to a user's personal privacy if it were to be leaked to the public?

The user's browser cookies

var size = 20; var x = 100; var y = 200; var ball = new Circle(size); ball.setPosition(x, y); What is the meaning of the x variable?

The x coordinate of the center of the circle

How many times will the following program print "hello"? - var i = 0; while(i < 10){ println("hello"); }

This code will loop infinitely

Which of the following is a benefit that online shopping websites provide over brick and mortar stores?

Users can easily see product reviews and determine if an item has been satisfactory for a large number of people

According to the domain name system (DNS), which of the following is a subdomain of the domain example.com?

about.example.com

In the following code: var MAX_NUMBER = 10; function sum(x, y){ var result = x + y; //Point A return result; } function start(){ var num1 = Randomizer.nextInt(0, MAX_NUMBER); var num2 = Randomizer.nextInt(0, MAX_NUMBER); println( sum(num1, num2) ); } Which variables exist at point A? In other words, which variables are in scope at point A? Which variables could you type at point A and the program would still work?

result, x, y, and MAX_NUMBER

A store has 20 apples in its inventory. How can you store this information in a JavaScript variable?

var numApples = 20;

How many different values can be represented using 4 bits?

16 different values

How many parameters go into the function sum, and how many return values come out of the function sum? function sum(first, second, third){ var result = first + second + third; println(first); println(second); println(third); return result; }

3 parameters go in, 1 return value comes out

What is printed by the following program? function product(x, y){ return x * y; } function difference(x, y){ return x - y; } function start(){ var x = 2; var y = 5; var value1 = product(x, y); var value2 = difference(y, x); var result = difference(value1, value2); println(result); }

7

The RGB encoding scheme encodes a color using 24 bit sequences. The first 8 bits encode the amount of red in the color, the next 8 bits encode the amount of green in the color, and the last 8 bits encode the amount of blue in the color. Which of the following is a true statement about the color encoded by this binary sequence: 1110 1001 0111 1100 0000 1111

This color is mostly red.

function start(){ 2 var circle = new Circle(40); 3 circle.setPosition(getWidth() / 2, getHeight() / 2); 4 circle.setColor(Color.blue); 5 } But when we run this code, we don't see the circle. What is missing from our start function?

We create the circle and position it correctly on the screen, but we never add it to the screen. We need to add the line add(circle); after line 4

A computer program uses 3 bits to represent integers. When the program adds the decimal (base 10) numbers 6 and 2, the result is 0. Which of the following is the best explanation for this result?

an overflow error occurs

There are trade-offs involved in choosing a compression technique for storing and transmitting data.

data compression

Which of the following is considered an unethical use of computer resources?

earching online for the answers to CodeHS exercises and quizzes

What is the value of the boolean variable canVote at the end of this program? var age = 17; var isCitizen = true; var canVote = age >= 18 && isCitizen;

false

We want to print the phrase "CodeHS is the best" exactly 25 times. What kind of control structure should we use?

for loop

"It's a bird! It's a plane! No, it's Superman!" We want to write a function isSuperman that takes in two parameters isBird and isPlane and returns true if it is in fact Superman, and false otherwise. If it's not a bird and it's not a plane, it must be Superman. Which of the following functions is the correct implementation of isSuperman?

function isSuperman(isBird, isPlane){ return !isBird && !isPlane; }

What are the coordinates of the center of the window?

getWidth() / 2, getHeight() / 2

In a graphics canvas, what are the coordinates of the bottom right corner of the window?

getWidth(), getHeight()

You want to read input from the user to know how many apples they would like to buy. Which statement should you use to read in a number from the user

var applesToBuy = readInt("How many apples would you like? ");

You are splitting up all of your apples equally between 3 people. Which statement below will calculate how many apples will be left over?

var leftOver = numApples % 3;

We want to position a Circle circle on our canvas to be at a random position, but we want to keep the entire shape on the screen. Which of the following will accomplish this?

var x = Randomizer.nextInt(circle.getRadius(), getWidth() - circle.getRadius()); var y = Randomizer.nextInt(circle.getRadius(), getHeight() - circle.getRadius()); circle.setPosition(x, y);

We want to simulate constantly flipping a coin until we get 3 heads in a row. What kind of loop should we use?

while loop

In the following function printThreeTimes: function printThreeTimes(word){ println(word); println(word); println(word); } What is the parameter of the function?

word


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

ECON 2113 Test 1 Review: Chapter 1

View Set

Week 9: Budget Deficits and the Public Debt

View Set

HM 380 Hotel Management Quiz Questions

View Set