Java Interview Questions
- 0of 0 votes
AnswersDifference between applets and application.
- elsewu December 28, 2012 in United States| Report Duplicate | Flag | PURGE
Mathworks Applications Developer Java - 0of 0 votes
AnswersWrite a program to shuffle a deck of 52 cards and shuffle them equally to 4 players
- Anil December 23, 2012 in United States for DLP| Report Duplicate | Flag | PURGE
Symantec Quality Assurance Engineer Java - 0of 0 votes
AnswersWrite a program that takes an array of numbers, and then prints out all the possible pairs of numbers that sum up to the value N.
- Anil December 23, 2012 in United States for AWS
E.g., if the array contains the numbers {0, 1, 2, 2, 3, 4, 5} and the target value N is 4, then the output would be (0, 4), (1, 3), (2, 2).| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Java - 0of 0 votes
AnswersI have two threads, both contain data from a database table. One thread performs some operation and update the data in the database table whereas second thread has not yet done any operation. Second thread does operation after some time and wants to update the operation. Since the first thread has already updated the data in the database table, second thread has stale data. How can we manage so that table should have the actual data not the stale data.
- Mr D December 22, 2012 in India| Report Duplicate | Flag | PURGE
Cisco Systems Java - 0of 0 votes
Answersint n=99;
- Mr D December 22, 2012 in India
int unsignedShift = n>>>2;
System.out.println("unsignedShift="+unsignedShift);
The above result gives "unsignedShift=24". The question is if 24 is given how can I get back the original value ie n ie 99. How to do it for both positive and negative integer. How to do it in java.| Report Duplicate | Flag | PURGE
Cisco Systems Java - 0of 0 votes
AnswersPhonebook contains number and name.
- Anonymous December 12, 2012 in India
1.use the java collection to add these entry (name and string).
2.Search the name by number
3.Remove the entry (name and string ) by using name.
I need to do this in Java...But if you can suggest me some Collection that can be used here, I shall do that....
I thought of :
1.using Hashmap,but here both name and number will be key....which wont be good...
2.Another option is to wrap both phone and number in an object and then add them to the list.And then Iterating and adding to the list.
Any other suggestions..?| Report Duplicate | Flag | PURGE
Accenture Software Engineer / Developer Java - 0of 0 votes
AnswersPrint below series in java
- Anonymous December 12, 2012 in India
*** 1***
**2 *2**
*3*3*3*
4*4*4*4| Report Duplicate | Flag | PURGE
Accenture Software Engineer / Developer Java - 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
AnswersWhy character array is better than string for storing password in java?
- maria November 26, 2012 in Bangladesh| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersFind the union of non-overlapping ranges,
- shaik November 25, 2012 in India
e.g; given an array {0,3,1,5,7,9,8,13} where 0 is starting point and 3 is the end point and so on.
The output should be {0,5,7,13}| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Java - 0of 0 votes
AnswersI have Created Dynamic Web Application...
- cobra November 24, 2012 in India
there is user table with column "enabled" to check if the user is already logged in
enabled = true --> logged in otherwise not
if i logged in , i cannot loggin at the same time in anothe r browser ..
but if i logged in and close the browser, how can i handle further loggin ??| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
Answers1. Remove the words where last character is a capital letter from a given sentence and then reverse the characters of each word
- maria November 21, 2012 in Bangladesh| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersFrom a given a sentence, find the word which contains more than 1 vowels and print all special characters.
- maria November 21, 2012 in Bangladesh
Input: This is a test sentence, good luck.
Output: Total words which contain more than 1 vowels: 2
The special characters are: , .| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersFrom a given string of numeric values, print the individual numbers in words separated by space.
- maria November 21, 2012 in Bangladesh
Input: “2490”
Output: two four nine zero| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersHow inter-thread communication can be done?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Overstock.com Software Engineer / Developer Java - 0of 0 votes
AnswersDifference between == and equals
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Overstock.com Software Engineer / Developer Java - 0of 0 votes
AnswersDifferent ways to create/track session in web application?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Overstock.com Software Engineer / Developer Java - 0of 0 votes
AnswersWhat would you change about Java?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Overstock.com Software Engineer / Developer Java - 0of 0 votes
AnswersHow to create Annotations?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Overstock.com Software Engineer / Developer Java - 0of 0 votes
AnswerWhat is GOTCHA in Java generic? Hint: Legacy code implementing collection
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Overstock.com Software Engineer / Developer Java - 0of 0 votes
AnswersWhat would you change about Java?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Overstock.com Software Engineer / Developer Java - 1of 1 vote
AnswerHow to make object immutable?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Qualcomm Applications Developer Java - 0of 0 votes
AnswersWhy do we need to override hashcode and equals methods?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Qualcomm Applications Developer Java - 0of 0 votes
AnswersWhat is MVC?
- Survivor November 20, 2012 in United States| Report Duplicate | Flag | PURGE
Qualcomm Applications Developer Java - 2of 2 votes
Answerswrite a program to perform divison operation of two numbers without using /, %, and modules operatot
- kiran November 15, 2012 in India| Report Duplicate | Flag | PURGE
ThoughtWorks Developer Program Engineer Java - 0of 0 votes
AnswersDictionary d: boolean isWord(String)
- fghprovider November 08, 2012 in United States
Input: "thisisawesome"
Output:
this is awesome
this is awe some
isWord("this") == true
isWord("esome") == false| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
AnswerGiven a list of objects or strings with the index information, the list has some gaps inside.
- cloudyware November 05, 2012 in United States
Implement a function to take a starting number and the total number, return the new list to contain all the items not in the given list.
eg. Given list1: {item1, item2, item3, item5, item6, item8, item9}, starting number is 3, total number is 10, then return the list2: {item4, item7, item10, item11, item12, item13, item14, item15, item16, item17}| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 0of 0 votes
Answerprogram to get n number of input and change it as 2 power n+1 and find whether the number is prime or not
- rbhavya62 November 05, 2012 in India| Report Duplicate | Flag | PURGE
Student student Java - 0of 0 votes
Answersprogram to get a list of arrays like 121 121 121 and eliminate duplicate and print 121 as output
- rbhavya62 November 05, 2012 in India| Report Duplicate | Flag | PURGE
Student student Java