Monday 11 June 2012

TCS placement paper (Technical)


Interview Question 1 :

Some directives are used to turn ON and OFF compiler specific features. For example, a compiler could be able to perform loop optimization and this could be invoked via these directives. What are these directives called ?


Answer : Pragma Directive. (This is bit tough question which you might not be aware of.)
------------------------------------------------------------------------------------------------------------
Interview Question 2 :

#ifndef preprocessor directive can be used to avoid multiple inclusions of a header file. State True or False.

Answer: Yes, it is True. For example the below code includes "headerfile.h" only if it is not already included.

#ifndef headerfile.h
#define headerfile.h
#endif
------------------------------------------------------------------------------------------------------------
Interview Question 3

Name two different types of polymorphism ?

Answer:
This is a prominent question from OOPS concepts. Two types of polymorphism are a) Overloading and b) Overriding
------------------------------------------------------------------------------------------------------------
Interview Question 4

Define Storage Classes and Name four types of storage classes ?

Answer:
Storage classes are specifiers define lifetime and scope of variables. Four types of Storage classes include Auto, Register, Extern and Static.
------------------------------------------------------------------------------------------------------------
Interview Question 5 :

What is the prime difference between While and Do While Loop ?

Answer :

Though while and do-while are loop statements, in Do While it is assured that the statements within the loop will be executed at least once (even if the condition fails.)
------------------------------------------------------------------------------------------------------------
Interview Question 6 :

2) What is the difference between a = ++b and a = b++ ?

Answer :

The first statement a = ++b can be broken down into two statements b = b + 1 followed by a = b. Hence b will be incremented first and will be assigned to a. Hence values of a and b will be same at the end.

The second statement a = b++ can be broken down into two statements a = b followed by b = b + 1. Hence b will be assigned to a. Only after this assignment b will be incremented. Hence values of a and b will be different at the end.
------------------------------------------------------------------------------------------------------------
Interview Question 7 :

3) A C program is compiled into native (binary) code by the compiler. Similary what will be generated out of JAVA program source by JAVA compiler ?

Answer :

JAVA program will get compiled into bytecode instead of native (binary) code.
------------------------------------------------------------------------------------------------------------
Interview Question 8

Amongst calloc and malloc subroutines, which one of them will initialize the allocated memory to zero.


Answer:
This question would require you to know basics of calloc and malloc memory allocating subroutines (or functions).Its calloc with does initialize allocated memory to zero.
------------------------------------------------------------------------------------------------------------
Find the output of the following .

9) main()
 {
  float me = 1.1;
   double you = 1.1;
     if(me==you)
         printf("I love U");
       else
   printf("I hate U");
}

a) I love U
b) I hate U
c) Both a) & b)

Answer: I hate U
------------------------------------------------------------------------------------------------------------
10) main()
{
   static int var = 5;
         printf("%d ",var--);
     if(var)
  main();
}

a) 12345
b) 54321
c) 15243

Answer: 5 4 3 2 1
------------------------------------------------------------------------------------------------------------
11) main()
{
   int c[ ]={2.8,3.4,4,6.7,5};
      int j,*p=c,*q=c;
        for(j=0;j<5;j++) {
           printf(" %d ",*c);
           ++q;
}
        for(j=0;j<5;j++)
{
   printf(" %d ",*p);
  ++p;
}
}

a) 2 2 2 2 2 4 2 3 5 5
b) 2 2 2 2 2 2 5 4 6 3
c) 2 2 2 2 2 2 3 4 6 5

Answer  2 2 2 2 2 2 3 4 6 5
------------------------------------------------------------------------------------------------------------
12) main()
{
    extern int i;
     i=20;
      printf("%d",i);
}

a) compiler error
b) Linker error
c) Runtime error

Answer  compiler error

------------------------------------------------------------------------------------------------------------
13) Which is the term used for information hiding in OOPS?

a) abstraction
b) encapsulation
c) polymorphism

Answer encapsulation
------------------------------------------------------------------------------------------------------------
14)  Distributed systems are used for

a) Resource sharing
b) Load sharing
c) Fault tolerance
d) All the  above

Answer  All the above
------------------------------------------------------------------------------------------------------------
15) Which of the following features is supported by Object Oriented Programming?

a) Abstraction
b) Encapsulation
c) Inheritance
d) All the above

Answer: All the above
------------------------------------------------------------------------------------------------------------
16) Which of the following statements is true considering OOP (Object Oriented Programming)?

a) State defines the attribute of an object
b) Behaviour defines the attribute of an object
c) State defines the functions to modify the behaviour of an object
d) none of the above

Answer: 1



No comments: