Hi Friends,
I hope you all have read all my previous Java Interviews:
Here in this post, I'm sharing interview questions asked in OLX.
Question 1:
If you have three, you have three. If you have two, you have two, but if you have one, you have none. What is it?
Answer:
Choices
Question 2:
3 bulbs 3 switches problem:
There is a room with a door [Closed] and three light bulbs. Outside the room, there are 3 switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door, you can't change them. Identify each switch with it's bulb.
Answer:
Turn on 1 switch and keep it on for 5 minutes. Now turn it off and turn on 2nd button and enter the room. Now the bulb which is ON maps to ON switch.The hot bulb maps to previous switch [which was turned on first] and 3rd bulb maps to 3rd switch.
Question 3:
REST API must use HTTP. Is that true or false?
Answer:
FALSE
Question 4:
A resource in the context of REST is (or may be) which one of these:
Answer:
All of the above
Question 5:
Suppose you have a "Worker" table as shown below. You have to write a SQL query to find employees with different salary.
Show only 2 Columns in output: first_name and salary.
Answer:
select distinct w1.salary , w1.first_name
from Worker w1, Worker w2
where w1.salary = w2.salary
AND w1.worker_id = w2.worker_id;
Question 6:
Write SQL query to display first 5 records from the table shown above?
Answer:
select * from worker LIMIT 5;
Question 7:
What is the difference between UNION and UNION ALL?
Answer:
UNION removes duplicate records. UNION ALL does not.
There is a performance hit when using UNION instead of UNION ALL, since the database server must do additional work to remove the duplicate rows. But usually , we don't want the duplicates especially when developing reports.
Question 8:
What are foreign key and super key?
Answer:
Foreign Key:
Foreign key maintains referential integrity by enforcing a link between the data in two tables.
Foreign key in child table references the primary key in parent table.
The foreign key constraint prevents actions that would destroy the link between the child and parent table.
Super key : It is a column or a combination of columns which uniquely identifies a record in a table.
e.g.:
Super key stands for superset of a key. e.g. We have a table Book with columns:
Book (BookID, BookName, Author)
So, in this table we can have:
That's all from this Interview.
Hope this post helps everybody in their job interviews.
Thanks for reading!!
I hope you all have read all my previous Java Interviews:
- Java Interview @ OrangeMantra
- Java Interview @ SAP
- Java Interview @ GalaxE
- Java Interview @ Concirrus
- Java Interview @ NexGen
- Java Interview @ Capgemini
- Java Interview @ Dew Solutions
- Java Interview @ RBS
- Java Interview @ WDTSJava Interview @ Aricent
- Java Interview @ Handygo
Here in this post, I'm sharing interview questions asked in OLX.
Question 1:
If you have three, you have three. If you have two, you have two, but if you have one, you have none. What is it?
Answer:
Choices
Question 2:
3 bulbs 3 switches problem:
There is a room with a door [Closed] and three light bulbs. Outside the room, there are 3 switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door, you can't change them. Identify each switch with it's bulb.
Answer:
Turn on 1 switch and keep it on for 5 minutes. Now turn it off and turn on 2nd button and enter the room. Now the bulb which is ON maps to ON switch.The hot bulb maps to previous switch [which was turned on first] and 3rd bulb maps to 3rd switch.
Question 3:
REST API must use HTTP. Is that true or false?
Answer:
FALSE
Question 4:
A resource in the context of REST is (or may be) which one of these:
- Thing
- Object
- Real World Entity
- An account
- An Item
- A Book
- All of the above
Answer:
All of the above
Question 5:
Suppose you have a "Worker" table as shown below. You have to write a SQL query to find employees with different salary.
Show only 2 Columns in output: first_name and salary.
Answer:
select distinct w1.salary , w1.first_name
from Worker w1, Worker w2
where w1.salary = w2.salary
AND w1.worker_id = w2.worker_id;
Question 6:
Write SQL query to display first 5 records from the table shown above?
Answer:
select * from worker LIMIT 5;
Question 7:
What is the difference between UNION and UNION ALL?
Answer:
UNION removes duplicate records. UNION ALL does not.
There is a performance hit when using UNION instead of UNION ALL, since the database server must do additional work to remove the duplicate rows. But usually , we don't want the duplicates especially when developing reports.
Question 8:
What are foreign key and super key?
Answer:
Foreign Key:
Foreign key maintains referential integrity by enforcing a link between the data in two tables.
Foreign key in child table references the primary key in parent table.
The foreign key constraint prevents actions that would destroy the link between the child and parent table.
Super key : It is a column or a combination of columns which uniquely identifies a record in a table.
e.g.:
Super key stands for superset of a key. e.g. We have a table Book with columns:
Book (BookID, BookName, Author)
So, in this table we can have:
- (BookID)
- (BookID, BookName)
- (BookID, BookName, Author)
- (BookID, Author)
- (BookName, Author)
as our super keys.
Each super key is able to uniquely identify each record.
That's all from this Interview.
Hope this post helps everybody in their job interviews.
Thanks for reading!!
Nice blog, Thank you for this blog is very informative. pg in greater noida
ReplyDelete