Amazon Campus Online Test Questions

Shubham Kumar
7 min readFeb 17, 2019

Role: Software Development Engineer

Job Profile: Passionate, hard-working, and talented Software Development Engineer who can build innovative & mission critical system software applications & tools. You will have an enormous opportunity to make a large impact on the design, architecture, and development of consumer products. You will be responsible for the delivery and support of large-scale, multi-tiered, distributed software applications and tools.

Eligibility Criteria →

→60% or 6 CGPA and above candidates

→B.Tech/ M.tech — CSE/IT/ECE/EEE

→MCA

Job Location →

→Bangalore →Hyderabad →Chennai →Delhi

Pay Package →

SDE OFFER Component Package (INR) Base 13,00,000

1st Year Sign-On → 3,50,000

2nd Year Sign-On → 2,25,000

RSU Value vested over 4 Years

Year 1–5%

Year 2–15%

Year 3–40%

Year 4–40%

Test Process →

20 Objective (Tech MCQ)

2 Programming

Allowed programming languages

C,C#,C++,C++14,Clojure,DErlang,F#,Go,Groovy,Haskell,Java,Java 8,JavaScript(Node.js),JavaScript(Rhino),Julia,Kotlin,Lisp,Lisp (SBCL), Lua,OCaml,Objective-C,Octave,PHP,Pascal,Perl,Python,Python 3,R(RScript),Racket,Ruby,Rust,Scala,Swift,Visual Basic

List of questions which were asked during the online test →

Battle Begins😎

1. Which of the following is an inorder traversal of a tree whose postorder traversal is 10, 9, 23, 22, 27, 25, 15, 50, 95, 60,40, 29?

a)9,10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
b)9,10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
c)29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
d)95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29

Ans:a

Explanation:

2. In OOP, a friend function of a class has exclusive access to which members of that class?

a)Private & protected members
b)Public & protected members
c)Private & public members
d)Private members
e)Protected members

Ans : a

Explanation :

3.In Networking, which of the following is NOT an example of application layer protocol?

a)HTTP
b)SMTP
c)FTP
d)TCP

Ans:d

Explanation :

4. If a machine needs 200 seconds to sort 200 bills by using bubble sort, how many bills will it sort in 800 seconds?

a)400
b)800
c)750
d)1000

Ans:b

Explanation:

Sorting 200 bills make the comparison as 2008* 199/2 = 19900 comparison.

In 800 sec, it will sort 80000 comparisons 800= 4x200,

find n, n (n-1)/2 = 80,000, so n= 400.

400 bills will be sorted in 800 seconds.

5.If the disk queue of I/O block requests is 98,37,14,124,65,67 with the disk head initially at 32 how many disk moves are required when FCFS is used?

a) 310
b) 315
c) 321
d) 324

Ans: c

Explanation: Total disk movement = 66 + 61 + 23 + 110 + 59 + 2 = 321.

6. In which of the following page-replacement policies does Belady’s anomaly occur?

a)FIFO
b) Optimal
c)LRU
d)MRU

Ans:a

Explanation: Belady’s anomaly proves that it is possible to have more page faults when increasing the number of page frames while using the First in First Out (FIFO) page replacement algorithm.

7. In OOP, which of the following is used to achieve runtime polymorphism?

a) A friend function
b) A virtual function
c)Operator overloading
d)Function overloading

Ans:b

Explanation:

8.In OOP, which of the following concepts allows a class object to be used inside another class?

a)Encapsulation
b)Abstraction
c)Composition
d)Inheritance

Ans:c

Explanation: In real-life, complex objects are often built from smaller, simpler objects. For example, a car is built using a metal frame, an engine, some tires, a transmission, a steering wheel, and a large number of other parts. A personal computer is built from a CPU, a motherboard, some memory, etc.. Even you are built from smaller parts: you have a head, a body, some legs, arms, and so on. This process of building complex objects from simpler ones is called composition

9.In an operating system, which of the following system programs combines the separately compiled modules of a program into a suitable form for execution?

a)Assembler
b)Linking loader
c)Cross compiler
d)Load and go

Ans : b

10. In SQL, which of the following commands is used to add a column to a table in a database?

a)ALTER TABLE <table name> ADD <column name>
b)MODIFY TABLE <table name> ADD <column name>
c)MODIFY TABLE <table name> INSERT <column name>
d)ALTER TABLE <table name> INSERT <column name>

Ans:a

Explanation:

11. What is the postfix expression for the following prefix expression:
*+pq-rs

a)pq + rs-*
b)pqrs +-*
c)pq + rs *-
d)pq+-rs*

Ans:a

Explanation:

12.In Networking, which of the following defines the purpose of Ping?

a) It measures the round-trip time.
b) It reports packet loss.
c) It reports latency.
d) All of these

Ans:b

13. How many nodes does a complete binary tree with N leaves contain?

a)2N
b) N
c) 2N-1
d) N-1
e) 2(N-1)

Ans:c

Explanation:

14. Which of the following system programs joins individually compiled modules of a program to form an executable module?

a)Assembler
b)Linking loader
c)Cross compiler
d)Load and go

Ans: b

15. Which of these is an expression for runtime in T(n) for the following recurrence: T(n)=4T (n/ 2) + n²

a)O(n²)
b)O(nlogn)
c)O(n²logn)
d)O(nIog²n)

Ans:c

Explanation:

T(n) = 4T(n/2) + n2
= n2 + 4[4T(n/4) + n²/4]
= 2n2 + 16T(n/4)
= ...
= k⋅n2 + 4kT(n/2k)
= ...

The process stops when 2k reaches n.
k = log2n
T(n) = O(n2logn)

16. An operating system uses FIFO policy for page replacement. It has 4-page frames, with no pages loaded at the start. The system first accesses 100 distinct pages in a specific order and then accesses the same 100 pages in the reverse order. How many page faults will occur?

a)199
b)197
c)200
d)196

Ans:d

Explanation: Access to 100 pages will cause 100-page faults. When these pages are accessed in reverse order, the first four accesses will not cause a page fault. All other access to pages will cause page faults. So the total number of page faults will be 100 + 96.

17.In C, which of the following bitwise operators is used to turn off a specific bit in a number?

a) &&
b) &
c) ||
d) !

Ans:b

18. In networking, why does the internet protocol use the time-to-live field in the IP datagram header?

a)To ensure packets reach their destination within the specified time
b)To discard packets that reach later than the specified time
c)To limit the time for which a packet gets queued in intermediate routers
d)To prevent packets from endlessly circulating on the Internet or other networks.

Ans:c

Explanation:

19.In C, which of the following expressions is used to represent the a[w][x][y][z] array element as a pointer expression?

a) ((a+w)+x+y+z)
b) ((((a+w)+x)+y)+z)
c) *(*(*(*(a+w)+x)+y)+z)
d) (((a+w)+x)+y+z)

Ans:c

Explanation: like for a[i]=*(a+i)
similarly the above expression will be given by *(*(*(*(a+i)+j)+k)+l)

20.S and Q are two semaphores initialized to

1. Statements processed by a process P0 are as follows: wait(S) ;
wait (Q);………Signal (S); Signal (Q); Statements processed by a process P1 are as follows: wait(Q); wait(s); ……signal(Q); signal(S);
What does this result in?

a)Semaphore
b)Deadlock
c)Signal
d)Interrupt

Ans:b

Coding Questions →

Profit Sort :

You are given the profit of a company for N days and Q queries are prepared on this file. Each query contains two integers L and R.

Write a program to calculate the number of days on which the profit fall between the range L and R (both inclusive).

Input format

* First line: N
* Second line: N space-separated integers(denoting the profit for each day)
* Third line: Q
* First line in each query: L and R

Output Format

Print the number of days on which the profit is greater than or equal to L and less than or equal to R

Constraints

1<N<10⁵
1<Profit for each day <10⁷
1<Q<10⁵
1<L, R<10⁵

Sample Input
5
23 13 10 2 33
5
7 11
10 30
1 10
2 40
5 6

Explanation:

For First Query, we have profits of value 10 in the given range.
For Second Query, we have profits of value 10,13,23 in the given range.
For Third Query, we have profits of value 2,10 in the given range.
For Fourth Query, we have profits in the given range.
For Fifth Query, we have no profits in the given range

Sample Output:

1 3 2 5 0

Such hard questions MY GOD 😲!!!!!! Save me 😪

ANS :

#include<stdio.h>
cons int MAXSIZE=100005
int solve (int N, int profit[MAXSIZE],int l, int r)
{
int count_number=0;
int j;
for(j=0; j<N;j++)
{
if(profit[j]>= l && profit[j]<=r)
{
count_number++;
}

return count_number;
}

}

int main()
{
int n;
scanf(“%d”, &n);
int profit[MAXSIZE];
for(int i=0;i<n;i++)
scanf(“%d”,&profit[i]);
int q;
scanf(“%d”,&q);
while(q — )
{
int l,r;
scanf(“%d%d”,&l,&r);
printf(“%d\n”,solve(n,profit,l,r));

}
return 0;

}

If you liked it press the clap icon as many times you can and also don’t forget to FOLLOW for more updates💖.

--

--

Shubham Kumar

Tech Geek || Programmer|| Software Developer|| DSC-Lead @ Google