Easy Tutorial
For Competitive Exams
Placement Papers Cisco Page: 2
14640.Cisco Technical Test

Given two sorted lists of size m and n respectively. The number of comparisons needed in the worst case by the merge sort algorithm will be?

mn
max(m,n)
min(m,n)
m+n-1
14641.Which indicates pre-order traversal?
Left sub-tree, Right sub-tree and root
Right sub-tree, Left sub-tree and root
Root, Left sub-tree, Right sub-tree
Right sub-tree, root, Left sub-tree
14642.What is the output of following program?

include

int main()

{

int n;

for (n = 9; n!=0; n--)

printf("n = %d", n--);

return 0;

}

9 8 7 6 5 4 3 2 1
9 7 5 3 1
infinite loop
9 7 5 3
Explanation:

The variable n will never evaluate to 0 so the loop will run for infinite times.

14643.How many times LogicGuns will be printed?

include

int main()

{

int i = -5;

while (i <= 5)

{

if (i >= 0)

break;

else

{

i++;

continue;

}

printf("LogicGuns");

}

return 0;

}

5 times
10 times
infinite times
0 times
Explanation:

The loop will break when i becomes 0 so nothing gets printed.

14644.What will be the output of the following program on GCC compiler?

include

int main() {

int x=4, y, z;

y = --x;

z = x--;

printf("%d, %d, %d\n", x, y, z);

return 0;

}

4, 3, 3
4, 3, 2
3, 3, 2
2, 3, 3
Explanation:

In the statement " y = --x ", the value of x is decremented and gets stored in y i.e. y = 3.

In the statement " z = x--", the value of x i.e. 3 is stored in z then, it is decremented and becomes x=2.

14645.Which of the following operation is illegal in structures?
Typecasting of structure
Pointer to a variable of same structure
Dynamic allocation of memory for structure
All of the mentioned
14646.How many enumerators will exist if four threads are simultaneously working on an ArrayList object?
1
2
3
4
14647.Which constructs an anonymous inner class instance?
Runnable r = new Runnable() { };
Runnable r = new Runnable(public void run() { });
Runnable r = new Runnable { public void run(){}};
System.out.println(new Runnable() {public void run() { }});
Explanation:

D is correct. It defines an anonymous inner class instance, which also means it creates an instance of that new anonymous class at the same time. The anonymous class is an implementer of the Runnable interface, so it must override the run() method of Runnable.

Option A is incorrect because it doesnt override the run() method, so it violates the rules of interface implementation.

Option B and C use incorrect syntax.

14648.Which method must be defined by a class implementing the java.lang.Runnable interface?
void run()
public void run()
public void start()
void run(int priority)
Explanation:

Option B is correct because in an interface all methods are abstract by default therefore they must be overridden by the implementing class. The Runnable interface only contains 1 method, the void run() method therefore it must be implemented.

14649.What will be the output of the following program on GCC?

include

int message();

int main() {

int x,y,z;

x=y=z=-1;

z=++x && ++y || ++z;

printf(" x=%d y=%d z=%d\n", x,y,z);

return 0;

}

x=0 y=-1 z=0
x=0 y=-1 z=1
x=0 y=1 z=0
Compiler Error
Explanation:

The operator `&&` has higher priority than the operator `||`. In the expression " z= (++x && ++y) || ++z", the value of x is incremented to 0 i.e. false value. Since, the 1st condition of && evaluates to false, 2nd condition of && operator is not tested and y remains unchanged.

Now, expression becomes "z = 0 || ++z". If the first condition of || operator evaluates to false, the 2nd condition of the operator will be tested also. Thus, value of z is incremented to 0. Finally, the result of the expression i.e. 0 is assigned to z.

Share with Friends