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)

#2 Are both the outputs of code segment (i) and code segment (ii) equal?

#3 What are the values of i and j at the end of the code fragment?

#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.

#5 What is the output of the following code segment?

#6 What will be the output of each of the code fragments?

#7 Consider the following code segment. What will be printed as a result when the code is executed?

#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?

#9 Which of the following results in assigning a value of 10 to an integer variable ‘b’?

#10 What is the output of the following program?

finish