Friday, 30 March 2012

Aptitude Question

In a group of 70 people, 37 like coffee, 52 like tea and each person likes at least one of the two drinks. How many people like both coffee and tea?
Let A and B denote the sets of people who like coffee and tea respectively. Then by inclusion-exclusion principle, number of people who like both coffee and tea = number of people who like coffee + number of people who like tea - number of people who like either coffee or tea = 37+52-70=19.

Aptitude Question

In a certain language, if ‘water’ is called ‘black’, ‘black’ is called ‘tree’, ‘tree’ is called ‘blue’, ‘blue’ is called ‘rain’, ‘rain’ is called ‘pink’ and ‘pink’ is called ‘fish’, what will the color of the sky be called in that language?
The answer depends very much on the heuristics of the person. You can think your own way, here some particular objects are assigned code names and then a question is asked, that is to be answered in the code language.
The color of the sky is ‘blue’. As given that ‘blue’ is called ‘rain’. Hence, the answer is ‘rain’.

Aptitude Question

Pointing towards Reeta, Nikhil said,"I am the only son of her mother's son".How is Reeta related to Nikhil?
Reeta's mother's  son-Reeta's brother.So,Nikhil is the son of Reeta's brother or Reeta is Nikhil's aunt.

Aptitude Question

void main()
{
int g=200*200/200;
printf(“%d”,g);
}
Ans: d The maximum value an integer can hold is 32,767. If we multiply 200*200 we will get a value 40,000, which is greater than the value that an integer can store.

Aptitude- Predict the output

void main() {
static int i=5;
if(--i)
{
main();
printf("%d ",i);
}
}
Ans: c The variable "I" is declared as static, hence memory for I will be allocated for only once, as it encounters the statement. The function main() will be called recursively unless I becomes equal to 0, and since main() is recursively called, so the value of static I ie., 0 will be printed every time the control is returned.

Tuesday, 27 March 2012

Interview question (Software)- Advantages of compiled Vs Interpreted languages

As compiled languages tend to result in marginally faster applications, one might think that compiled languages should always be used instead of interpreted languages. However, there are many reasons for using interpreted languages rather than compiled ones. The primary reasons are that,
  1. Faster development.
  2. Easier updating.
  3. Easier debugging with only a marginal increase in processing time.
  4. Portable, able to be run without being modified for different computing environments.  
In contrast, compiled languages take,
  1. More time for development.
  2. More time for update.
  3. More time for debugging.
  4. Generally faster to run.
  5. Difficult to reverse engineer. 
Because interpreted languages require the distribution of source code, proprietary software applications prefer to use compiled languages to prevent competitors (and customers) from seeing how their software was designed and built. By compiling into bytecode, however, otherwise interpreted languages such as Python and, to some extent, Java are effectively able to circumvent this issue while still remaining portable and being only marginally slower than if they were compiled into machine code.