
AP Computer Science Principles Pre-Test
Authored by Ethan Batres
Information Technology (IT)
10th Grade
Used 6+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a valid way to declare a variable in JavaScript?
`var myVariable;`
`variable myVariable;`
`declare myVariable;`
`int myVariable;`
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet?
var x = 5;
var y = 10;
console.log(x + y);
15
510
5
10
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a function declaration in JavaScript?
`function myFunction() {}`
`let myFunction = function() {}`
`const myFunction = () => {}`
`myFunction() = function() {}`
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the scope of a variable declared with `var` inside a function?
Global
Local to the function
Local to the block
Local to the script
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code:
function add(a, b) {
return a + b;
}
What will `add(3, 4)` return?
34
7
12
undefined
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a valid way to create a list (array) in JavaScript?
`var myList = {};`
`var myList = [];`
`let myList = ();`
`let myList = <>;`
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
var fruits = ['apple', 'banana', 'cherry'];
console.log(fruits[1]);
apple
banana
cherry
undefined
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?