Java Interview Questions
- 0of 0 votes
Answersprogram to print only alphabets by getting input as j@1vu etc
- rbhavya62 November 05, 2012 in India| Report Duplicate | Flag | PURGE
Student student Java - 0of 0 votes
AnswersGiven a matrix of 0's and 1's find the number of groups of 1's in the matrix.
- smdmustaffa October 30, 2012 in United States
A group of 1's can be formed if a 1 is present either vertically or horizontally to the adjacent 1 and not diagonally.
1 0 0 0
1 1 0 0
0 0 1 1
0 0 1 1
The above matrix has two groups of 1's while the one shown here has only one group
1 1 0 0
1 1 1 0
1 1 0 0
No restrictions on space complexity was given but the interviewer did mention that the time complexity should be efficient and that it should work for extremely large matrix's as well.| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm Data Structures Java Matrix - 0of 0 votes
AnswersProblem : Move the chess piece "KNIGHT" from any location on a
- kalyani October 29, 2012 in India
"3 x 3" Chess Board and make it go to the far right
hand bottom corner^. Chess Board in the problem is
not the usual Chess Board of 8 x 8.
KNIGHT starting position may be any position on board
Program should exit when knight moves to 3 x 3 corner.
Here is how my Chess board looks.
1 2 3
-------------------------
| | | |
1 | | | |
| | | |
-------------------------
| | | |
2 | | | |
| | | |
-------------------------
| | | |
3 | | | X | <<<<------- KNIGHT should reach
| | | | this square.
-------------------------
Remember: KNIGHT moves in specific way such as 2 steps in
one direction and 1 step left/right.
If the KNIGHT starts are position (2,2) then it cannot move further and
you have to throw exception with some error message.
We are not interested in any UI programming.
Run command: "java <some class> x y", where x is x-coordinate
and y is y-coordinate(starting position of Knight)
on the chess board. For this problem x & y could be
1(min) and 3(max) values and any value(2) in between.| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 0of 0 votes
AnswersIn a hashmap, how to delete all the odd entries? i.e, if hash map contains key1, value1, key2, value2, key3, value3, ... we've to delete all the odd entries, that is to remove all the keys alone without deleting values
- SK October 28, 2012 in United States| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersWhat is a HashMap? What is one advantage of using a HashMap versus a TreeMap?
- msito October 25, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Java - 0of 0 votes
AnswersGiven an array of integers, find the mode and the frequency of the mode. If possible, print each number along with its frequency.
- msito October 25, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Arrays Java - 0of 0 votes
AnswersIn a hash map with objects as keys,
- msito October 25, 2012 in United States
a) what method do you have to overwrite to do this?
b) how would you resolve a collision?| Report Duplicate | Flag | PURGE
Amazon Intern Data Structures Java - 0of 0 votes
AnswersGiven an O(v+e) time algorithm to compute the path in a connected in unidirectional graph that traverse each edge in each direction exactly once.Describe how u can find ur way out of the maze if u r given a large supply of pennies.using JAVA
- mayankbitmesra October 19, 2012 in India| Report Duplicate | Flag | PURGE
Student student Student student Java - 0of 0 votes
Answersassume that dictionary has only 5 words...
- vikashanand338 October 17, 2012 in United States
APPLE,APE,BABY,BALL,CAT
write a program which will accept a string and list all possible words in the dictionary which start with that string.use binary trees for fast retreival in java| Report Duplicate | Flag | PURGE
Google Student student Java - 0of 0 votes
Answersassume that dictionary has only 5 words...
- vikashanand338 October 13, 2012 in United States
APPLE,APE,BABY,BALL,CAT
write a program which will accept a string and list all possible words in the dictionary which start with that string.use binary trees for fast retreival in java| Report Duplicate | Flag | PURGE
Student student Student student Java - 0of 0 votes
AnswersWrite a program to traverse and return all nodes of an n-ary tree(note: not a binary tree).
- chaos October 06, 2012 in India for Kindle| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
AnswersI have an arrayList A which contains say 2,3,5,7,8
- gadha October 04, 2012 in India
I have another arrayList B which contains 1, 3
Now taking the elements of B as the locations, I need to remove the elements of A present in that locations. So, basically I need to remove the element 2(position 1) and 5(position 3) from A. How to achieve it as we know that once one element got removed from an arrayList,the positions will be auto adjusted.| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Java - 0of 0 votes
AnswersWhat's the difference of Abstract and Interface class
- MaxxxChou September 26, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
AnswersHow to modify the file content using Java?
- BeginnerInProgrammingWorld September 26, 2012 in United States
For eg--> I have a file that contains following data
1,21,Azhar
2,22,Ali
3,34,ABC
4,123,XYZ
.....
I want to modify the content of this file to:
1,Azhar
2,Ali
3,ABC
4,XYZ| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswersHow can I redirect the output obtained on console to a new file using JAVA?
- BeginnerInProgrammingWorld September 14, 2012 in United States| Report Duplicate | Flag | PURGE
Java - 0of 0 votes
AnswerWrite a program to identify the name of current city where you are using IP addresses.
- kakani.shrikant September 11, 2012 in United States| Report Duplicate | Flag | PURGE
ASU Student student Java - 0of 0 votes
AnswersInput: String array. The output of the method should be the String value out of the array passed in that contains the least number of numeric characters. If two Strings have the same number of numeric characters, return the longest String. If two Strings have the same number of numeric characters and are the same length, return the String that appears first in the input array. If the array is empty, return null.
- Yev September 01, 2012 in United States for Products| Report Duplicate | Flag | PURGE
GrubHub Software Engineer / Developer Java - 0of 0 votes
AnswersRe write the below program in such a way that it should print
- kinshu August 30, 2012 in United States
Hi
Good Bye
******NOTE: You cannot change the main method*******
Class Program{
Public static void main(String args[]){
Try{
System.out.println(“Hi”);
System.exit(0);
}
Finally{
System.out.println(“Good Bye”);| Report Duplicate | Flag | PURGE
SAS Research Software Engineer / Developer Java - 0of 0 votes
AnswersWriteTestA class on such a way that the below program’s output should be false.
- kinshu August 30, 2012 in United States
***NOTE: You cannot override equals method***
Class A{
TestA testObj = new TestA();
System.out.println(testObj.equals(testObj));
}| Report Duplicate | Flag | PURGE
SAS Research Software Engineer / Developer Java - 0of 0 votes
AnswersInput: two unsorted char arrays A,B(may contain dups) where A.length <= B.length
- Yev August 29, 2012 in United States
If each character in A appears in B, return true. Else false. Write the code.| Report Duplicate | Flag | PURGE
Wireless Generation Java Developer Java - 0of 0 votes
Answersimplement the following interface in java :
- Anonymous August 24, 2012 in India
public interface ExamImmutableQueue<E>{
public ExamImmutableQueue<E>enqueue(E e); /*returns the queue that adds an item into the tail of this queue without modifying this queue.
when this queue represents the queue(2,1,2,2,6)and we enqueue the value 4 into this queue.
this method return a new queue (2,1,2,2,6,4) and this objects still represents the queue(2,1,2,2,6)
*/
}| Report Duplicate | Flag | PURGE
WorksApp Java - 0of 0 votes
AnswersGenerating all unique Substrings of a String using Suffix Array (For making it a fast Process) in lexicographic order
- newhere August 18, 2012 in India
in java.| Report Duplicate | Flag | PURGE
Algorithm Java - 0of 0 votes
Answers[LinkedList] What's wrong with the code below under JDK 1.4? Fix it. How about JDK 1.5?
- light_handle August 15, 2012 in United States
LinkedList[] ll = new LinkedList[3];
ll[1].add(1);
ll[1].add("red");
ll[2].add(2);
ll[2].add("green");
ll[3].add(3);
ll[3].add("blue");| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 0of 0 votes
AnswersThis is a newbie interview question from Statistic industry.
- Xiaonb August 13, 2012 in CHINA
there are a vector v {c1, c2,c3...c(n-1)} and a variable x, try to construct a polynomial eg:
p(x)= c1 + c2*x + c3*x^2 + ... + c(n-1)*x^(n-1)| Report Duplicate | Flag | PURGE
Coding Java - 0of 0 votes
Answershow will you implement dictionary for client . suppose data is stored in database .you don't need to implement dictionary but explain entire interaction and systems involved .
- chad July 31, 2012 in United States
The interviewer was not interested in knowing how dictionary is internally implemented . he was more interested in understanding bigger picture ie. high level , eg.
i explained you will have ajax call from client page to fetch matching words, explained arguments that i will pass in ajax , explained high level server side api , how this api will interact with db and how it will send information back to client .
i think we should discuss high level perspective eg. designing the system overall architecture rather than dictionary algorithm| Report Duplicate | Flag | PURGE
Big Fish Software Engineer / Developer Java - 0of 0 votes
Answerssteps involved to deploy a web services . interviewer was interested in high level tasks involved in deploying a webservices and how client will access it.
- chad July 31, 2012 in United States| Report Duplicate | Flag | PURGE
Big Fish Software Engineer / Developer Java - 0of 0 votes
AnswersWhich data structure will you use for creating a real world dictionary?
- kavitha July 31, 2012 in United States| Report Duplicate | Flag | PURGE
Adobe Software Engineer in Test Data Structures Java - 0of 0 votes
AnswersYou have a sorted circular linked list and a sorted linear linked list. Write a program to merge these two arrays and create a new sorted circular linked list
- kavitha July 31, 2012 in United States| Report Duplicate | Flag | PURGE
Adobe Software Engineer in Test Data Structures Java - 0of 0 votes
AnswersHi,
- Anonymous July 27, 2012 in United States
Can any one tell me how to sort combination of int and float numbers,i am confused that how to use collection as different objects are involved
for example if i want to sort numbers 2,5.7,6.2.3
then what collection can i use??| Report Duplicate | Flag | PURGE
Java