Training high school teachers to teach AP Computer Science Principles
Select Page
Programming Quiz
Results
#1 How does the array ‘a’ look like after executing the following code segment? (a.length represents the length of the array)
{11, 3, 4, 20, 23, 18}
{10, 2, 4, 20, 22, 18}
{18, 22, 20, 4, 2, 10}
#2 Are both the outputs of code segment (i) and code segment (ii) equal?
Yes, output of (i) and (ii) are same
No, output of (i) differs from output of (ii)
Syntax of (i) is correct and (ii) is incorrect
Syntax of (i) is incorrect and (ii) is correct
#3 What are the values of i and j at the end of the code fragment?
i = 40, j = 30
i = 40, j =35
i = 50, j = 30
i = 50, j =35
#4 ‘a’ is an array containing percentages of six students. We have to assign grades for each of the student based on their percentages as stated above. Consider the below two code segments (i) and (ii) and determine which of them would correctly assign the grades.
(i) is correct
(ii) is correct
Both (i) and (ii) are correct
Depends, sometimes (i) is correct and sometimes (ii) is correct
#5 What is the output of the following code segment?
120
1
5
Code results in infinite loop.
#6 What will be the output of each of the code fragments?
(i) 0 (ii) 1
(i) 0 (ii) 0
(i) 1 (ii) 1
(i) 1 (ii) 0
#7 Consider the following code segment. What will be printed as a result when the code is executed?
2 4 6 8 10
1 3 5 7 9
1 2 3 4 5 6 7 8 9 10
1 3 5 7 9 10
#8 [8, 1, 10, 6, 4, 2] Assume that these are the elements of a stack ‘S’ such that 2 is the top most element and 8 is the element at the bottom of the stack. Note that, push(), pop(), peek() are the methods used with the stack; push(int x) inserts an integer x onto the top of the stack; int pop() removes the integer at the top of the stack and returns that integer; int peek() returns the integer at the top of the stack without removing it from the stack. How does the Stack look like after executing the following code segment?
[8, 1, 10, 6, 12, 17]
[17, 5, 12, 6, 10, 1, 8]
[8, 1, 10, 6, 12, 5, 17]
[2, 4, 6, 10, 20, 25]
#9 Which of the following results in assigning a value of 10 to an integer variable ‘b’?
int b = (int)Math.sqrt(81) + 1;
int b = (int)Math.abs(-5) + 5;
int b = (int)Math.pow(2,3) + 2;
All the above
#10 What is the output of the following program?
Touch screen available! iphone
Touch screen not available! Samsung TV
Touch screen available! iphone Touch screen not available! Samsung TV
Touch screen not available! Samsung TV Touch screen available! iphone