Java Developer Interview Questions
- 0of 0 votes
AnswersWhat are checked exceptions
- meek June 05, 2013 in United States| Report Duplicate | Flag | PURGE
VMWare Inc Java Developer Java - 0of 0 votes
AnswersGiven +ve numbers in an array . Put the even #s to the left of the array and the odd to the right side of the array . Don't use extra array.
- meek June 05, 2013 in United States| Report Duplicate | Flag | PURGE
VMWare Inc Java Developer Coding Java Probability - 0of 0 votes
Answerscode a singleton class
- meek June 05, 2013 in United States| Report Duplicate | Flag | PURGE
VMWare Inc Java Developer Java - 1of 1 vote
AnswersRakesh likes skiing a lot. That's not very surprising, since skiing is really great. The problem with skiing is one have to slide downwards to gain speed. Also when reached the bottom most point one has to wait for ski-lift to get to higher altitude.
- oglA June 04, 2013 in India
Rakesh seeks your help to know the longest run possible with the given peaks. That altitude of different peaks is given by a grid of numbers. Look at this example:
7 2 3 4 5
36 37 38 34 6
33 44 46 40 7
24 43 42 41 8
35 32 47 30 9
One can ski down from one peak to a connected peak if and only if the height decreases. One peak is connected to another if it's at left, at right, above or below it. In the sample map, a possible ski path would be 36-33-24(start at 36, end at 24). Of course if one would ski 46-44-43-42-41-30-9....3-2, it would be a much longer run. In fact, it's the longest possible. There could be more than one longest ski path, but all Rakesh needs from you is to tell maximum number of peaks he could cover for a given map, in this case it is 14.
Input ::
All input comes from input.txt file. The first line contains the number of test cases N. Each test case starts with a line containing the name (it's a single string), the number of rows R and the number of columns C. After that follow R lines with C numbers each, defining the heights. R and C won't be bigger than 100.
Output ::
For each test case, print a line to output.txt containing the name of the area, a colon, a space and the length of the longest run (maximum points covered) one can slide down in that area.
Sample Input
2
Manali 10 5
56 14 51 58 88
26 94 24 39 41
24 16 8 51 51
76 72 77 43 10
38 50 59 84 81
5 23 37 71 77
96 10 93 53 82
94 15 96 69 9
74 0 62 38 96
37 54 55 82 38
Narkanda 5 5
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Sample Output
Manali: 7
Narkanda: 25| Report Duplicate | Flag | PURGE
Java Developer Algorithm - 3of 3 votes
AnswersGiven an array with different numbers and a number of C,so how to find all the combinations which the sum is C..like..array={1,2,3,4},C=3,,return is 2,which contains two combinations{{1,2},{3}}.
- onyasGM May 23, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Java Developer Algorithm - 0of 0 votes
AnswersTwo numbers are missing from the first hundred numbers. They are NOT sorted. How to find them?
- devenster May 22, 2013 in India
You can't sort.. and can't iterate one by one.. has to be less than O(N)? Can't use stack , set or any collection interface or in fact any other data structure or array!| Report Duplicate | Flag | PURGE
Siemens Java Developer Algorithm - 0of 0 votes
AnswersUsing these 3 functions:
INCREMENT: READ N1 WRITE N1 + 1 MINUS: READ N1, N2 WRITE N1 - N2 MULTIPLY: READ N1,N2 WRITE N1*N2
Define these four functions: Greater than, Equality, Nonequality, Divide.
- Sam May 21, 2013 in UK| Report Duplicate | Flag | PURGE
Java Developer Algorithm - 0of 0 votes
AnswersHow can you implement multiplication operator using increment operator (No arithmetic operation is allowed)?
- Sam May 21, 2013 in UK| Report Duplicate | Flag | PURGE
Java Developer Algorithm - 0of 0 votes
AnswersGive three Hash tables has some values.you need compare three hash tables and store the common values in fourth hash table?
- amit.grynch May 19, 2013 in India| Report Duplicate | Flag | PURGE
HCL Java Developer - 0of 0 votes
AnswersThere is a sorted array of integers (suppose sorted in "ascending order"). How will you find a specific element in an array? You can not use traditional iterative method to find a specific element in an array.
- gunsnroses23k May 08, 2013 in United Kingdom| Report Duplicate | Flag | PURGE
Ebay Java Developer Algorithm - 0of 0 votes
AnswerYou are in a maze, and you need to find all possible path from an entrance to an exit. Here are the constraints: ● The maze is represented by a 2D grid. ● Spots that you can step on are represented by a 0. ● Pits that you will fall into (aka spots that you cannot step on) are represented by a 1. ● The entrance is represented by a 2. ● The exit is represented by a 3. ● Each path can only have two endpoints; entrance and exit. You cannot use the entrance or exit more than once for each path. ● You have to step on every spot exactly once. ● You can only move like a King in chess (horizontally or vertically but not diagonally)
- narendra May 04, 2013 in India
Here is an example of the maze: 2 0 0 0 0 0 0 0 0 0 0 0 0 3 1 Possible paths are:
Your program should read from standard input with a series of integers with whitespace as delimiter. The first two integer represents the width and height of the maze. It will then be followed by width*height more integers. Your output should be an integer which shows the total number of possible path. Marks will be given for efficiency as well.| Report Duplicate | Flag | PURGE
Java Developer - 0of 0 votes
AnswersGiven the fact that you have a map <SessionId, SessionValueObject> , . The sessionValueObject contains timestamp as well associated with the session. In generality, we are maintaining a key value pair. And each session has a timestamp associated with it.
- jimmy514in April 11, 2013 in United States
Now the question was given a particular timestamp associated with a sessionValueObject, we need to implement a data structure such that,
given a timestamp t1, we need to free/ remove all the sessionValueObjects associated after the timestamp t1.
How do we do this efficiently?| Report Duplicate | Flag | PURGE
Bank of America Java Developer - 0of 0 votes
AnswersWrite code for api printInt(int n) assume you have putch(char ch) available to you. Don't use standard library.
- Bharat April 06, 2013 in India| Report Duplicate | Flag | PURGE
Java Developer - 0of 0 votes
AnswersWhere is primitive data stored in java memory?
- ab April 03, 2013 in United States| Report Duplicate | Flag | PURGE
Harman Kadron Java Developer Java - 0of 0 votes
AnswersDifference betwen Aggregation and composition. What is enum. Write a design pattern except singleton. Write binary search. Write recursive binary search. Elaborate on man in middle attack. How you create a branch - why in svn? . Explain the architecture of your previous work experience. explain thread concept of synchronization.
- jimmy514in March 21, 2013 in India| Report Duplicate | Flag | PURGE
RoviCorp Java Developer - 0of 0 votes
AnswersGiven a set of consecutive integersA[1....n] and an integer value x,y, need to find the list of subset of integers in A[1....n] which has x integers and sums up to y.
- kondala.ravikumar March 20, 2013 in India for DEV
Say A = [10,11,12,13,14,15,16,17,18,19,20], X = 4 and Y = 55,
it should give the values of (10,14,15,16),(10,11,15,19),(10,11,16,18),(10,12,16,17) and so on..
Write an algorithm to find all the subsets.| Report Duplicate | Flag | PURGE
SWAPTON SOLUTIONS Java Developer Algorithm - 0of 0 votes
AnswersWrite a method to compute the difference between two ranges. A range is defined by an integer low and an integer high. A - B (A “minus” B) is “everything in A that is not in B”
- asad February 05, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Java Developer Algorithm - 0of 0 votes
AnswersYou have given an array of Integers of size n, and a sliding window by 1 integer ,of size k <= n. you have to print minimum number in each window of size k.
- pandu.vdp January 30, 2013 in India
E.g: given array [3,9,0,3,18,6], i.e.n = 6 and window size k = 3
available windows for above array is [3,9,0] ,[9,0,3],[0,3,18], [3,18,6]
output should be : 0, 0, 0,3| Report Duplicate | Flag | PURGE
Chronus Java Developer Data Structures - 0of 0 votes
AnswersTime complexity of Hash Map storage and retrieval in Java.
- Saurabh January 28, 2013 in India| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Java - 1of 1 vote
AnswersWhat are immutable objects? What are their Advantages? Design a immutable object with Date object as a member attribute. NOTE : Since Date is mutable, he wanted to check whether I could resolve that. I dint though :(
- Saurabh January 28, 2013 in India| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Java Object Oriented Design - 0of 0 votes
AnswersWhich Design patterns have you worked on? What is Singleton? Design a Singleton Class. Make it thread safe.
- Saurabh January 28, 2013 in India| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Java Knowledge Based - 0of 0 votes
AnswerDescribe ACID properties in terms of a database transaction
- ravigupt January 19, 2013 in India| Report Duplicate | Flag | PURGE
United HealthGroup Java Developer Database - 0of 0 votes
AnswersDatabase server is in US and web server is in India, how will you handle time zone conversion?
- ravigupt January 19, 2013 in India| Report Duplicate | Flag | PURGE
United HealthGroup Java Developer Database - 0of 0 votes
AnswersGiven two arrays of integer, print out the values from first array which are not present in second array. Time complexity should be O(n)
- ravigupt January 19, 2013 in India| Report Duplicate | Flag | PURGE
United HealthGroup Java Developer Arrays - 0of 0 votes
AnswerCreate a class Graph, which must represent the graph data structure in java. What will be the difference between directional and unidirectional Graph? How would you represent the weight of the edges?
- Lyubomir December 21, 2012 in United States| Report Duplicate | Flag | PURGE
Hi5 Java Developer - 1of 1 vote
AnswerFor each subject topic(like Maths,Physics,Java,Sql), I have some urls.
- Anonymous December 15, 2012 in India
In each url,I have a list of questions.
Now on each click(lets say Physics),I shall hit all urls(which could be in thousands) and then parse through them to get all the questions and persist them to DB.
Please tell me what can be the high levl and low level design for this in Java(Explain patterns that cn be used,Threads etc...)| Report Duplicate | Flag | PURGE
Akamai Java Developer Algorithm - 0of 0 votes
AnswersWrite an algorithm to scan all anagrams in a word doc.
- Anonymous December 15, 2012 in India
This should be done in minimum time possible.| Report Duplicate | Flag | PURGE
Akamai Java Developer Algorithm - 0of 0 votes
AnswersThis was at a recent written test...
There is a toycar placed on a 5 by 5 board.We can give 5 commands to it ,
PLACE(X,Y,F) where x denotes X Axis,y denotes Y Axis and F denotes the direction to which its facing.
MOVE->Move will move the toycar one step in the direction where its facing
LEFT->Left will turn the toycar by 90 degrees to its left and face it to the new direction .Note:Left will not move the toycar, it will just change the direction
RIGHT->Right will turn the toycar by 90 degrees to its right and face it to the new direction .Note:Right will not move the toycar, it will just change the direction
REPORT->Report shall tell me the X Axis,YAxis and Direction of the toycar. like 0,0,NORTH
Note:You cannot move,left,right,report the toycar unless you place it.
Assume its a Prod level code, Solve it in Java only.
Below is my code and I haven't been selected, please tell me if there is better way to do it because my solution is correct but probably very basic.Thanks.
- Anonymous December 03, 2012 in Indiapackage com.ds; public class ToyCar { private ToyCar toycar; private boolean isToyPlaced; private int xAxis,yAxis; private enum Direction {EAST,WEST,NORTH,SOUTH}; private Direction direction; public int getxAxis() { return xAxis; } public void setxAxis(int xAxis) { this.xAxis = xAxis; } public int getyAxis() { return yAxis; } public void setyAxis(int yAxis) { this.yAxis = yAxis; } public Direction getDirection() { return direction; } public void setDirection(Direction direction) { this.direction = direction; } ToyCar(){ } public ToyCar(int xAxis,int yAxis,Direction direction) { this.xAxis=xAxis; this.yAxis=yAxis; this.direction=direction; } public void place(int x,int y, Direction d){ if(x<0||x>5||y<0||y>5 || d==null){ System.out.println("Place Error:Attempt to place toy outside the box"); return; } toycar = new ToyCar(x, y, d); isToyPlaced=true; } public void move(){ if(!isToyPlaced){ System.out.println("Move Error:Attempt to Move Toy without placing in board"); return; } if(toycar.getDirection().equals(Direction.EAST)){ int newPosition=toycar.getxAxis()+1; if(newPosition<0||newPosition>5){ System.out.println("Move Error:Attempt to place toy outside the box"); return; } toycar.setxAxis(newPosition); }else if(toycar.getDirection().equals(Direction.WEST)){ int newPosition=toycar.getxAxis()-1; if(newPosition<0||newPosition>5){ System.out.println("Move Error:Attempt to place toy outside the box"); return; } toycar.setxAxis(newPosition); }else if(toycar.getDirection().equals(Direction.NORTH)){ int newPosition=toycar.getyAxis()+1; if(newPosition<0||newPosition>5){ System.out.println("Move Error:Attempt to place toy outside the box"); return; } toycar.setyAxis(newPosition); }else if(toycar.getDirection().equals(Direction.SOUTH)){ int newPosition=toycar.getyAxis()-1; if(newPosition<0||newPosition>5){ System.out.println("Move Error:Attempt to place toy outside the box"); return; } toycar.setyAxis(newPosition); } } public void left(){ if(!isToyPlaced){ System.out.println("Left Error:Attempt to Move Toy without placing in board"); } if(toycar.getDirection().equals(Direction.EAST)){ toycar.setDirection(Direction.NORTH); } else if(toycar.getDirection().equals(Direction.WEST)){ toycar.setDirection(Direction.SOUTH); } else if(toycar.getDirection().equals(Direction.NORTH)){ toycar.setDirection(Direction.WEST); } else if(toycar.getDirection().equals(Direction.SOUTH)){ toycar.setDirection(Direction.EAST); } } public void right(){ if(!isToyPlaced){ System.out.println("Right Error:Attempt to Move Toy without placing in board"); } if(toycar.getDirection().equals(Direction.EAST)){ toycar.setDirection(Direction.SOUTH); } else if(toycar.getDirection().equals(Direction.WEST)){ toycar.setDirection(Direction.NORTH); } else if(toycar.getDirection().equals(Direction.NORTH)){ toycar.setDirection(Direction.EAST); } else if(toycar.getDirection().equals(Direction.SOUTH)){ toycar.setDirection(Direction.WEST); } } public void report(){ if(!isToyPlaced){ System.out.println("Report Error:How can i report when I am not on board"); return ; } System.out.println(toycar.getxAxis()+" , "+toycar.getyAxis()+" , "+toycar.getDirection()); } public static void main(String[] args){ ToyCar to = new ToyCar(); to.place(0, 0, Direction.WEST); to.left(); to.move(); to.report(); } }
| Report Duplicate | Flag | PURGE
CSC Java Developer Java - 0of 0 votes
AnswersGiven an unsorted array, how to divide them into two equal arrays whose sum of difference is minimum.
- Psycho September 29, 2012 in United States
Can it be done in o(n)?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Morgan Stanley Java Developer Coding