





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






The following program should draw a circle on the screen 1 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? - correct answer ✅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 What is the output of the following program: (Assume the user enters 'Florence' then 'Fernandez'.) var first_name = readLine("What is your first name? "); var last_name = readLine("What is your last name? "); var whole_name = first_name + last_name; println (whole_name); - correct answer ✅FlorenceFernandez
Which of the following choices is a properly formed JavaScript variable name, meaning it is both legal in the JavaScript language and considered good style? - correct answer ✅userAge If you wanted to use the following code to draw a circle to the canvas with the radius, and x and y coordinates given by the user, how would you ask for this information? var circle = new Circle(radius); circle.setPosition(x, y); circle.setColor(color); add(circle); - correct answer ✅var x = readInt("What is the x coordinate? "); var y = readInt("What is the y coordinate? "); var radius = readInt("What is the radius of the circle? "); If you were given the following variables: var distance = 2; var time = 30;
add(circle); - correct answer ✅Draw a circle on the canvas that always touches the top and left sides of the canvas If a user enters a diameter value in the variable diameter, how would we use this to draw the correct sized circle? - correct answer ✅var circle = new Circle(diameter/2); circle.setPosition(100,100); add(circle); A store has 20 apples in its inventory. How can you store this information in a JavaScript variable? - correct answer ✅var numApples = 20; 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? - correct answer ✅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? - correct answer ✅var leftOver = numApples % 3; In a graphics canvas, what are the coordinates of the bottom right corner of the window? - correct answer ✅getWidth(), getHeight() What are the coordinates of the center of the window? - correct answer ✅getWidth() / 2, getHeight() / 2 In the following code: 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? - correct answer ✅The x coordinate of the center of the circle
What will be printed from the following: var x = 4 * 3 + 2 / 5; println(x); - correct answer ✅12. Which of the following lines of code would be considered the highest level of code? - correct answer ✅move(); Which of the following could be considered a computer? - correct answer ✅all of these choices On the AP exam, the ← operator is used for variable assignment. For example, a ← 10 assigns the value 10 to the variable a. On the AP Exam, the modulus operator is denoted by MOD. The MOD operator has the same precedence as the * and / operators. What will c evaluate to in the following code segment? a ← 18
b ← 4 c ← a MOD b - correct answer ✅ 2 What will the following code segment evaluate to? function start(){ var a = 10; var b = 5; var c = 2; var expression = ((a - b) * c) % 3; println(expression); } - correct answer ✅ 1 On the AP exam, INPUT() is used to accept a value from the user and DISPLAY() is used to display a value. Values that are displayed are NOT started on a new line, but do contain a space afterwards. Consider the code segment below. DISPLAY ("What is your name?") name ← INPUT () DISPLAY ("Hello")