Showing posts with label Amazon. Show all posts
Showing posts with label Amazon. Show all posts

Sunday, 6 March 2016

Amazon Whole Test Paper

Amazon Whole Test Paper
  Amazon Placement paper

1. Two tables emp(empid,name,deptid,sal) and dept(deptid,deptname) are there.write a query which displays empname,corresponding deptname also display those employee names who donot belong to any dept.
2. Write prefix and post fix notation for (a+b)*c-(d+e)^(f-g)
3. write program to swap 2 variables without using extra memory.
4. Find the output for the following C program fn f(x)
{
if(x<=0)
return;
else f(x-1)+x;
}
5. Find the output for the following C program main()
{
   intx=2,y=6,z=6;
   x=y=z;
   printf(%d",x)
}
6. Copy a a file form one host "amazon.chennai" to another host "anazon.bbsr"
7. You want to find out the value of the last element of an array. You write the following code. What will happen when you compile and run it.?
public class MyAr{
public static void main(String argv[]){
int[] i = new int[5];
System.out.println(i[5]);
}
}
1) An error at compile time
2) An error at run time
3) The value 0 will be output
4) The string "null" will be output.
8. . Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
9. Write a program to remove duplicates from a sorted array.
10. In C, if you pass an array as an argument to a function, what actually gets passed?
A.  Value of elements in array
B.  First element of the array
C.  Base address of the array
D.  Address of the last element of array
Ans-C


11. What will be the output of the program ?


A.  2, 3, 4, 5 B.  1, 2, 3, 4
C.  0, 1, 2, 3 D.  3, 2, 1 0
Ans-B

12. What will be the output of the program if the array begins 1200 in memory?
A.  1200, 1202, 1204 B.  1200, 1200, 1200
C.  1200, 1204, 1208 D.  1200, 1202, 1200
Ans-B
13. Which of the following statements are correct about an array?
1:  The array int num[26]; can store 26 elements.
2:  The expression num[1] designates the very first element in the array.
3:  It is necessary to initialize the array at the time of declaration.
4:  The declaration num[SIZE] is allowed if SIZE is a macro.
A.  1   B.  1,4
C.  2,3   D.  2,4
Ans-B
14. Which of the following function is used to find the first occurrence of a given string in another string?
A.  strchr()   B.  strrchr()
C.  strstr()   D.  strnset()
Ans-C
15. Which of the following function is correct that finds the length of a string?
Ans-A
16. What will be the output of the program in 16-bit platform (Turbo C under DOS) ?
A.  8, 1, 4    B.  4, 2, 8
C.  4, 2, 4    D.  10, 3, 4
Ans-B
17. Which of the following statements are correct ?
1:  A string is a collection of characters terminated by '\0'.
2:  The format specifier %s is used to print a string.
3:  The length of the string can be obtained by strlen().
4:  The pointer CANNOT work on string.
A.  A, B   B.  A, B, C
C.  B, D   D.  C, D
Ans-B
18. What is the wrong in this program
19. Point out the error in the program?
A.  Error: invalid structure member
B.  Error: Floating point formats not linked
C.  No error
D.  None of above
Ans-B
20. What is the similarity between a structure, union and enumeration?
A.  All of them let you define new values
B.  All of them let you define new data types
C.  All of them let you define new pointers
D.  All of them let you define new structures
Ans-B
21. What will be the output of the program ?
#include<stdio.h>
int main()
{
    enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
    printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
    return 0;
}
A. -1, 0, 1, 2, 3, 4   B. -1, 2, 6, 3, 4, 5
C. -1, 0, 6, 2, 3, 4   D. -1, 0, 6, 7, 8, 9
Ans-D
22. What will be the output of the program ?
A. 103 Dotnet    B. 102 Java
C. 103 PHP    D. 104 DotNet
Ans-A
23. In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.h
A.  During editing   B. During linking
C.  During execution  D. During preprocessing
Ans-D
24. Point out the error in the program
A.  Error: unexpected end of file because there is no matching #endif
B.  The number is odd
C.  Garbage values
D.  None of above
Ans-A
25. What are the different types of real data type in C ?
A. float, double    B. short int, double, long int
C. float, double, long double  D. double, long int, float
Ans-C
26. Which statement will you add in the following program to work it correctly?
A.  #include<conio.h> B.  #include<math.h>
C.  #include<stdlib.h> D.  #include<dos.h>
Ans-B
27. What do the following declaration signify?
int *ptr[30];
A.  ptr is a pointer to an array of 30 integer pointers.
B.  ptr is a array of 30 pointers to integers.
C.  ptr is a array of 30 integer pointers.
D.  ptr is a array 30 pointers.
Ans-B
28. What is x in the following program?
A.  x is a pointer
B.  x is an array of three pointer
C.  x is an array of three function pointers
D.  Error in x declaration
Ans-C
29. In the following code snippet can we declare a new typedef named ptr even though struct employee has not been completely declared while using typedef?
A. Yes    B. No
Ans-A
30. What will be the output of the program?
A.  3, 4, 4, 3 B.  4, 3, 4, 3
C.  3, 3, 4, 4 D.  3, 4, 3, 4
Ans-B
APTITUDE
Predict the output or error(s) for the following:
1.
2.
3.


4
5.


  2. What are the files which are automatically opened when a C file is executed?
  3. what will be the position of the file marker?
            a: fseek(ptr,0,SEEK_SET);
            b: fseek(ptr,0,SEEK_CUR);
  4. What is the problem with the following code segment?
            while ((fgets(receiving array,50,file_ptr)) != EOF)
  5. Predict the output or error(s)

  
  6. Predict the output or error(s)

  
7. In the following pgm add a  stmt in the function  fun such that the address of
    'a' gets stored in 'j'.


Ans- *k = &a
8. What are the following notations of defining functions known as?

Ans
   i.  ANSI C notation
  ii. Kernighan & Ritche notation
9. Is the following statement a declaration/definition. Find what does it mean?
  int (*x)[10];
Ans- Definition-x is a pointer to array of(size 10) integers.
10. . What is the output for the program given below

     typedef enum errorType{warning, error, exception,}error;
     main()
    {
        error g1;
        g1=1;
        printf("%d",g1);
     }
 
Ans- Compiler error: Multiple declaration for error
11. What is the output for the program given below
   typedef struct error{int warning, error, exception;}error;
     main()
    {
        error g1;
        g1.error =1;
        printf("%d",g1.error);
     }
Ans-1
12. What is the output for the program given below

Ans-bye
13. What is the output for the program given below


Ans-                              1       1       1       1
                                    2       4       2       4
                                    3       7       3       7
                                    4       2       4       2
                                    5       5       5       5
                                    6       8       6       8
                                    7       3       7       3
                                    8       6       8       6
                                    9       9       9       9
14. Declare an array of N pointers to functions returning pointers to functions             returning pointers to characters?
Ans- (char*(*)( )) (*ptr[N])( );
15. There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong?
16. Is there any difference between the two declarations,
1.      int foo(int *arr[]) and
2.      int foo(int *arr[2])
Ans-No
17. What is the subtle error in the following code segment?
18. What is wrong with the following code?
19. What is the hidden bug with the following  statement?
  assert(val++ != 0);
20. Is the following code legal?
struct a
    {
int x;
struct a b;
    }
Ans-No
21. Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
      aType *b;
              };
}
Ans-no
22. Which version do you prefer of the following two,
1) printf(“%s”,str);      // or the more curt one
2) printf(str);
Ans-1
23. Find the output.
  main()
{        
char a[4]="HELL";
printf("%s",a);
}
Ans- HELL%@!~@!@???@~~!
24. Printf can be implemented by using  __________ list.
Ans-Verbal Length argument
25. The command which gives the  device of our system
Ans-Who
26. Which of following is correct:
a)For loops can be nested
b)For Loops may use the same Index
c)For loops cannot be overllapped
Ans:a,c

27. when the system starts which will execute?
Ans- Booting loader

28. ada is _____________ language
      a)modular b)object based c)object oriented d)functional

29. The maximum level of the tree is
Ans-depth of the tree

30. which is used for storing pictures or graphics
a) mbr  b)mar  c)frame buffer  d)sdram

Friday, 19 February 2016

Amazon Placement Paper Freshers - Interview Questions

Amazon Placement Paper Freshers - Interview Questions

 
  

  Company Name:  Amazon
  Interview Location:  Hyderabad 
   Written Test has 2 Sections A, B



                       

In Section A there were 20 Questions: 
Technical Questions: 15
Aptitude: 5
Time: 30 min

The first round was online, It had 20 Multiple choice questions and 2 coding, MCQ’s where quite simple, Technical where easy it had questions on finding the Output, Complexity, and more importance was in Data Structure, and especially TREE. 

Some Sample Questions
1.Two tables emp(empid,name,deptid,sal) and dept(deptid,deptname) are there.write a query which displays empname,corresponding deptname also display those employee names who donot belong to any dept.

2.Display the employees whose salary is less than average salary.

3.what is the output of the program
main()
{
int c=5;
printf("%d %d %d",c,c<<2,c>> 2);
}
4.
main()
{
int a[8][10],c=0,i,j;
 for(i=0;i<10;
i++) for(j=0;
j<8;j++) a[j][i]=c++;
printf("%d",a[3][6]);
}
5.What is the wrong in this program
main()
{
char *p,*q;
p=(char *)malloc(25);
q=(char*) malloc(25);
strcpy(p,"amazon" );
strcpy(q,"hyd");
strcat(p,q);
printf("%s",p);
}
6.write prefix and post fix notation for (a+b)*c-(d+e)^(f-g)
7.what is the output of the program
main()
{
int i=5;
printf("%d",fun(fun(fun(fun( fun(i))))));
}
void fun(int i)
{ if(i%2) return (i+(7*4)-(5/2)+(2*2));
else return (i+(17/5)-(34/15)+(5/2));
}

8.When it is always true Boolean fun
(node *p)
{
return ((p==null)||(p->next==null)|| (p->info<=p->next->info)&&( fun(p->next)));
}

a)when list is empty or has one node
b)when the ele are sorted in non decreasing order
c)when the ele are sorted in non increasing order
9.what is x here (x&&!(x&(x-1))==1)
a)x is always a prime
b)x is a power of 2
c)x is even d)x is odd

10 .What is the difference between deep copy and shallow copy

11.In java what is the difference between sleep() and wait() .

12.What happens when the parent process of a child process exits before the child ?

13.There are three persons A,B,C .A shots the target 6 times out of 7 shots .B shots 4 out of 5 shots .Then what is the probability of hitting the target twice when 2 persons are selected at random.

14.what is valid in cpp char *cp; const char *cpp; 1) cpp=cp; 2) cp=cpp;

15.write program to swap 2 variables without using extra memory.

16.write a shell command to find all java files present in nested directories.

17.There are 6 pairs of black socks and 6 pairs of white socks. What is the probability to pick a pair of black or white socks when 2 socks are selected randomly in darkness.

18.A string of alphanumeric is there. Find a string that starts with b and ends with 3 characters. section B (we have to write programs)