Java Interview Questions
- 0of 0 votes
AnswersIf given a binary file, with data like lat, long, weather, temp in key:value. It's a structured data how would u ingest it. what are the steps that are being taken before Hive process starts.
- Tom Walker June 07, 2015 in United States
- serde (serializartion deserialization). parque etc.| Report Duplicate | Flag | PURGE
Amazon Software Developer Algorithm Data Mining Data Structures Database Distributed Computing Java SQL - 0of 0 votes
AnswersAfter map phase partition, shifting, sorting happen. What does it mean?
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Mining Data Structures Database Java - 0of 0 votes
AnswerWhat is input split in hadoop.
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Mining Data Structures Database Java SQL - 0of 0 votes
AnswersAs I interviewing for Big data position. Asked Hadoop question :-
- Tom Walker June 07, 2015 in United States
Difference between TextInput vs Key Value format in Hadoop.| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Mining Data Structures Database Java design - 0of 0 votes
AnswersDesign Bing search.
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm Coding Database Java Object Oriented Design Software Design - 0of 0 votes
AnswersWhat's Hbase, Pig, used for? Why do we need Hbase if we can use Hive to query Hadoop?
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Developer Data Mining Data Structures Database Distributed Computing Experience Java Knowledge Based Large Scale Computing - 0of 0 votes
AnswersWhat are different phases of Map reduce operation - I think they were looking for split, combiners, partitioners, sorting phases of whole map reduce stage.
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Developer Data Mining Data Structures Database Distributed Computing Java Large Scale Computing SQL - 0of 0 votes
AnswersMy interview was for big data position for their Search team. They were looking for person with good Hadoop skill set :-
- Tom Walker June 07, 2015 in United States
1. Can you describe Hadoop Architecture? What are various components of it (Primary/Secondary namednodes, data node etc)? Explain working of each.| Report Duplicate | Flag | PURGE
Microsoft Software Developer Data Mining Data Structures Database Distributed Computing Ideas Java - 0of 0 votes
AnswersGiven Two classes A & B. How will B know if an instance of A is already created?
- SantoshSingh June 02, 2015 in India| Report Duplicate | Flag | PURGE
Oracle SDE-2 Java - 0of 0 votes
AnswersSuppose you are given a puzzle that is represented as a matrix with 0s and 1s, where a 0 indicates you’re allowed to move into that position and 1 means you’re not allowed to move in that position. Write a function that given a start position and an end position, returns a boolean value indicating if there exists a path from start to end. you are only allowed to move up, left, right and down. Diagonal movement is not allowed.
- anom May 28, 2015 in United States
Example #1
Input
0 0 1 0 1
0 0 0 0 0
0 1 1 1 1
0 1 1 0 0
start: 4,1
end 0,3
Output - true
Example #2
Input
0 0 1 1 1
0 1 0 0 0
1 1 1 1 1
0 0 0 0 1
start: 0,0
end: 1,2
Output - false| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 1of 1 vote
AnswersImplement a function that returns the i-th most popular item sold
- anom May 28, 2015 in United States
at xyz company. You cannot rely on any libraries.
Class Item {
String itemId;
int quantitySold;
}
/**
find the i-th most popular item in the list
**/
String find(List<Item> items, int i) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 2 votes
AnswersI have this element {1, 1, 2, 3}, so i have an duplicate element. I want generate combinations and my result should be: {1} {2} {3} {1 1} {1 2} {1 3} {2 3} {1 1 2} {1 1 3} {1 2 3} {1 1 2 3}. The order of element isn't important, {1 1 2 3} == {2 3 1 1}, but i wan't a duplicate result set.
- pasquale.restaino1992 May 25, 2015 in United States
My code is:
enter code herepublic List> powerSet1(List originalSet) { Date inizio = new Date(); int resultSize = (int) Math.pow(2, originalSet.size()); // resultPowerSet is what we will return List> resultPowerSet = new ArrayList>(resultSize);
// Initialize result with the empty set, which powersets contain by definition
resultPowerSet.add(new ArrayList<Elemento>(0));
// for every item in the original list
for (Elemento itemFromOriginalSet : originalSet) {
// iterate through the existing powerset result
// loop through subset and append to the resultPowerset as we go
// must remember size at the beginning, before we append new elements
int startingResultSize = resultPowerSet.size();
for (int i=0; i<startingResultSize; i++) {
// start with an existing element of the powerset
List<Elemento> oldSubset = resultPowerSet.get(i);
// create a new element by adding a new item from the original list
List<Elemento> newSubset = new ArrayList<Elemento>(oldSubset);
newSubset.add(itemFromOriginalSet);
// add this element to the result powerset (past startingResultSize)
resultPowerSet.add(newSubset);
}
}
logger.info(resultPowerSet);
Date fine = new Date();
long tempo = fine.getTime() - inizio.getTime();
logger.info ("durata genera combinazioni: " + tempo);
return resultPowerSet;
}
But this generate duplicate.| Report Duplicate | Flag | PURGE
Java Developer Java - 0of 0 votes
AnswersIn a Formula-1 challenge, there are n teams numbered 1 to n. Each team has a car and a driver. Car’s specification are as follows:
- Nitin Gupta May 06, 2015 in India
– Top speed: (150 + 10 * i) km per hour
– Acceleration: (2 * i) meter per second square.
– Handling factor (hf) = 0.8
– Nitro : Increases the speed to double or top speed, whichever is less. Can be used only once.
Here i is the team number.
The cars line up for the race. The start line for (i + 1)th car is 200 * i meters behind the ith car.
All of them start at the same time and try to attain their top speed. A re-assessment of the positions is done every 2 seconds(So even if the car has crossed the finish line in between, you’ll get to know after 2 seconds). During this assessment, each driver checks if there is any car within 10 meters of his car, his speed reduces to: hf * (speed at that moment). Also, if the driver notices that he is the last one on the race, he uses ‘nitro’.
Taking the number of teams and length of track as the input, Calculate the final speeds and the corresponding completion times.| Report Duplicate | Flag | PURGE
Google SDE1 Algorithm Arrays Data Structures Java Object Oriented Design - -1of 1 vote
Answersconsider a battlefield to be made up of square cells of unit dimensions. a soldier on the battlefield can move from a cell to all(8) of it's neighboring cells. soldier has a gun with with him which he can shoot the targets up to any distance along any of the 8 possible directions (north,east,west,south,north-east,north- west,south- east,south- west). also some sell are bulletproof which prevents bullets to pass but soldier can walk over them as if it were a normal cell.he can destroy the target from a bulletproof cell but not from a cell behind it.
- sarath.chalasani46 May 03, 2015 in India for dev
position of a target/ soldier can be given by the cell, they are on.given the position of the target, starting position of a target and position of all the bullet proof cells. you have to tell the position of closest shooting point i.e the cell from which, the soldier can shoot the target and is closest to the starting position of the soldier. if there are more than such cells, output all of them.
Input/output specifications :
Input specifications :
I) size of the battlefield { integer pair (N,M) : battlefield will be of N*M size )
II) staring position of the soldier {integer pair (i,j)}
III) position of the target {integer pair (x,y) : position of the cell on which target is mounted}
IV) position of the all bullet proof cells { list of integer pair a#b : each element in the list is a position of bullet proof cells }
output specifications :
sequential list of integer pair i#j (cell) that are closest shoot points and must fallow row wise traversal.
Note: if the output list contains four shoot points : (2,1), (1,2), (3,2), (2,4) on a 4x4 battle field.
then the correct output will be {1#2,2#1,2#4,3#2} not {1#2,2#1,3#2,2#4}
Examples:
Input : {2,2} {2,1} {2,2} {1#1,1#2}
output : 2#1
below is the method signature in java:
public static String[] nearest_shoot_point(int[] input1,int[] input2,int[] input3String[] input4){
}| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Java - 1of 1 vote
AnswersYou are given two objects, Student and Course, and there exist a many to many relation between them. One student can be enrolled for more than one course and there can be many students enrolled for a single course. Design an effective data structure to store such data keeping in mind that the time complexity for search should be optimum. A search can be for the list of students enrolled for a single course, or for the list of courses a single student is enrolled.
- angshu1986 May 01, 2015 in India| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Data Structures Java - 1of 1 vote
AnswersThe prime numbers between 1,000,000 and 1,000,100 are:
- Poornima April 28, 2015 in United States
1000003, 1000033, 1000037,1000039, 1000081, 1000099
and its sum is = 6000292.
What is the sum of all prime numbers between 1,000,000,000,000 and 1,000,000,100,000?| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersYou are given the Ancestor matrix of a Binary tree, write an C program/function to construct the corresponding tree.
- Poornima April 28, 2015 in United States
For example, the below tree:
10
/ \
5 30
/ \ \
4 8 40
/
1
Will have the following ancestor Matrix
1 4 5 8 10 30 40
1 0 1 1 0 1 0 0
4 0 0 1 0 1 0 0
5 0 0 0 0 1 0 0
8 0 0 1 0 1 0 0
10 0 0 0 0 0 0 0
30 0 0 0 0 1 0 0
40 0 0 0 0 1 1 0
Essentially, in the ancestor matrix, each node has a row and a column (may not be the same). The value at a[i][j] will be 1 iff node of Node representing j‘th column is the ancestor of node representing the i‘th row.
Write an C program/function that can construct the binary tree from a given Ancestor matrix(2 dimensional array as input to the function).| Report Duplicate | Flag | PURGE
Java - 1of 1 vote
Answersdesign a class (give different methods and variables that will be used) that will provide information about the allergy of a patient.
- katenaomi247 April 23, 2015 in United States
e.g. who reported the allergy(patient/doctor/relative), different symptoms of the allergy that are detected, severity, method that returns when was that
allergy detected in that patient. Along with info about disease if it is not allergy, and can be updated easily, how would you record the time of the disease report using java| Report Duplicate | Flag | PURGE
Cerner Corporation Software Engineer Coding Java Object Oriented Design - -1of 3 votes
AnswersWrite a function which returns the number of times the digit "1" appears in a number which is generated from raising 11 to the Nth power where N is passed in as an input parameter. The range of N is 0 to 1,000.
Be sure to unit test your solution.
For instance, If N is 3, the number is 1331 and the function returns 2.
If N is 5, the function returns 3.
If N is 10, the function returns 1 and so on.public int solution(int N) { ... }
You have 30 minutes to complete the problem.
- robertlaub April 17, 2015 in United States| Report Duplicate | Flag | PURGE
iCIMS Senior Software Development Engineer Java - 0of 0 votes
AnswersYou are given a system call
system.schedule(Runnable task, int seconds)
The function can handle only one invocation; for example, if called
system.schedule(task1, 3); system.schedule(task2, 6); system.schedule(task3, 9);
the first and second calls will be "forgotten". Only the third one will be scheduled.
- feqs April 15, 2015 in United States
Implement a class MyTimer with method mySchedule(Runnable, int) that can handle unbounded number of calls without forgetting. Use the system.schedule() function.| Report Duplicate | Flag | PURGE
Software Engineer Java - 0of 0 votes
Answersgiven an array (list) of integers return true(boolean function) if two of the numbers add to 12.
- nitz April 15, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Java - 0of 0 votes
AnswersTake a string as input and add the digits present in that
- Poornima March 31, 2015 in United States
string.
Ex:I/P="asdf12bgt3bh5j"
O/P=20
I/P="iuy2hjg4jhg8"
O/P=14
I/P="7 13"
O/P=20| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswerTake an array of integers as input. print the pair of
- Poornima March 31, 2015 in United States
prime number and even number. Remaining numbers
should appear at the last.
Ex: I/P=[1,5,9,7,3,6,8,13,2,4]
O/P=[5,6,7,8,3,4,1,9,13,2]| Report Duplicate | Flag | PURGE
Java - -2of 4 votes
Answerspublic class MyClass {
- MrA March 29, 2015 in United States
public static int num=1;
public static boolean flag=false;
public static void main(String[] args) {
Thread t =new Thread(new MyThread());
t.start();
MyClass.flag=true;
MyClass.num=10;
}
}
class MyThread implements Runnable{
public void run() {
while(!MyClass.flag){
Thread.yield();
}
System.out.println(MyClass.num);
}
}
Output of this code and the reason for the output?| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer Java - 0of 0 votes
AnswersWhen a Synchronied method is executed in a Java class, which Object is getting locked ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswerHow write your own annotations in Java ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswerIn JDBC, When you do the following
Class.forName("driver class name") Connection conn = DriverManager.getConnection()
How does JVM recognizes to give the exact driver's connection object which has been loaded by Class.forNAme in the previous line ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswersWhat is dependency injection and Inversion of Control in Spring ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswerIn Java Threadpool Executor, what are the possible rejection policies if all the threads are used.
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
Answer/* do not use any JAVA APIs(Ex:Calenders)
- pd March 20, 2015 in United States
Write a method that takes an instance of our new class SimpleDate and returns the first day of the next calendar quarter (i.e. Jan 1, 2000; April 1, 2000, etc.) as a SimpleDate.
/**
Simple data structure representing a Date
*/
public class SimpleDate {
protected int year = 0;
protected int month = 0;
protected int day = 0;
public SimpleDate (int year, int month, int day) {...}
public void setDate (int year, int month, int day) {...}
public void setYear (int year) {...}
public int getYear () {...}
public void setMonth (int month) {...}
public int getMonth () {...}
public void setDay (int day) {...}
public int getDay () {...}
}
// 3/17/2009 -> 4/1/2009| Report Duplicate | Flag | PURGE
StartUp SDET Java