Questions 1: Predict the output of the given pseudo code if the value of n is 35 :
Read n
i=0
While n%10!=0
n=n+3
i++
end while
n=n+i
write n
Answer: c
Questions 2: What will be the output of the given pseudo code if n = 10 ?
Read n
Initialize i to 5
while i < n do
increase sum by i
increment i
end while
Write sum
Answer: b
Questions 3: Predict the output of the given pseudo code if the value of number is 6:
Read number
k = 2
i = 2
while i<=number
k = k * i
i = i +1
end while
write k
Answer: c) 1440.0
Questions 4: What will be the number of " * " printed by the given pseudo code when input is 25?
Write "Please enter a number"
Read input
Repeat while input > 0
if( input > 0 and input <=10 )
Write *
else if ( input >10 and input <=20 )
Write **
else if ( input >20 and input< = 30 )
Write ***
input --
end if
end while
Answer: b
Questions 5: You have written the pseudo code given alongside for performing binary search in an array of elements sorted in ascending order. Which step to be followed in A to execute binary search successfully?
1.Compare x with the middle element.
2.If x matches with the middle element, we return the mid index.
3.A
4.Else ( x is smaller ) recur for the left half
Answer: b
Questions 6: You have a vehicle class, a car class, and a person class, you have to implement the functionalities of a bird, dog, cat, bus, auto and 2 specialized car classes for hybrid and electric vehicles.
Which of these options is the most efficient way to do so?
1.Make a new class for all the required methods and implement all methods separately.
2.Inherit the car class into the specialized car and then implement the extra methods.
3.Make a new class Big vehicles and then inherit properties from it to make the bus classes.
4.Inherit the person class to bird, dog, cat, and then override the methods that are not required.
5.Make new class animals and use this to make the dogs, cats and birds class.
6.Make a new three wheeled vehicle inherited from vehicle class for auto.
7.Inherit vehicle class for auto.
Answer: a
Questions 7: Class A contains two methods, namely “me” and “see”. Class B inherits Class A and overrides the “see” method. Class C also inherits methods from Class A and overrides the “see” method. Class B and class C are both inherited by class D using the concept of multiple inheritances.
In the given scenario, identify the problem generated by the behaviour of the “see” method?
Answer: c
Questions 8: Consider the given problem statement:
Problem statement :
Find the closest pair of points in an array of distinct points
Assume that you have solve this problem by comparing all pairs of points. What will be the complexity of this approach?
Answer: b
Questions 9: You are using the pseduo algorithm given alongside to sort an array using insertion sort.
Which of the following can be used in place of X to complete the algorithm?
1.Declare static void insertionSortRecursive(int arr[], int n) function.
2.if ( n < = 1 ) then return add more elements to array message.
3.Sort first n-1 elements.
4.Insert last element at its correct position in sorted array
int last = arr[n-1];
int j= n-2;
5.Move elements of arr[X], that are greater than key, to one position ahead of their current position.
Answer: c
Questions 10: Given alongside are two pseudo-class definitions in an Object Oriented Programming Language
Which of the following statements is true regarding the return type of Dog's seekFood() function?
public class Animal{
protected Food seekFood(){
return new Food();
}
}
public class Dog extends Animal{
protected Food seekFood(){
return new DogFood();
}
}
Answer: c