Java Interview Questions
- 0of 0 votes
AnswersWhat is Serial ID corresponding to serialization?
- Yev July 26, 2012 in United States| Report Duplicate | Flag | PURGE
Highbridge Capital Java Developer Java - 0of 0 votes
AnswersWhen/why would you not use the final keyword?
- Yev July 26, 2012 in United States for Risk Metrics| Report Duplicate | Flag | PURGE
Highbridge Capital Java Developer Java - 0of 0 votes
AnswersWhat is volatile?
- Yev July 26, 2012 in United States for Risk Metrics| Report Duplicate | Flag | PURGE
Highbridge Capital Java Developer Java - 0of 0 votes
AnswersWhat lock does the thread acquire if you call a synchronized object/static method?
- Yev July 26, 2012 in United States for Risk Metrics| Report Duplicate | Flag | PURGE
Highbridge Capital Java Developer Java - 0of 0 votes
AnswersWhat are the cons of making every object Serializable?
- Yev July 26, 2012 in United States for Risk Metrics| Report Duplicate | Flag | PURGE
Highbridge Capital Java Developer Java - 0of 0 votes
AnswersWhere/when would you use final?
- Yev July 26, 2012 in United States for Risk Metrics| Report Duplicate | Flag | PURGE
Highbridge Capital Java Developer Java - 1of 1 vote
AnswersHow to stop recursion stack as soon as we find a result.
- Ashupriya July 22, 2012 in United States
e.g. in a Tree recurion where the Order of the algo is O(n) and suppose we find the result just after 4 calls, can we empty the recursion stack and stop the ececution right away...| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm Data Structures General Questions and Comments Ideas Java - 0of 0 votes
Answershow do u authenticate and perform authorization if your server is stateless in java . how does entire process work . please explain detailed architecture for it.
- chad July 18, 2012 in United States| Report Duplicate | Flag | PURGE
Medio Systems Software Engineer / Developer Java - 0of 0 votes
AnswersWhen singleton wont work as singleton??
- sarthakiter July 17, 2012 in India| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Java - 0of 0 votes
AnswerWhat is a weakHashMap??weak References??
- sarthakiter July 17, 2012 in India
xplain with example| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Java - 0of 0 votes
Answerswrite a program so that it'll find all the possible combination of a string avoiding palidromes
- sarthakiter July 11, 2012 in United States
example:if the input is:"abcde"
output would be:"a","b","c","d","e","ab","ac","ad","ae","bc","bd","be","cd","ce","de","abc","abd","abe",...
but if you have already "abc",dont create"cba"| Report Duplicate | Flag | PURGE
Adobe Java Developer Java - 0of 0 votes
Answerswrite a program so that the
- sarthakiter July 11, 2012 in India
input be a no suppose 5 it will give
output as
1+2*2+3*3*3+4*4*4*4+5*5*5*5*5| Report Duplicate | Flag | PURGE
Adobe Java Developer Java - -1of 1 vote
AnswersWhat is the main use of interface ? Provide a real time example that shows it
- Shobhit July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Java - 0of 0 votes
AnswersWhat is the importance of overriding in java ? Give any real life example . How is it increasing the code reusability and robustness .? Cant we create new function instead of override ? What difference will it make ?
- Shobhit July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Java - 0of 0 votes
AnswersHow can I read a file in, compile, and execute it at run time?
- chad July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
AnswerHow can I get a list of all symmetric key generators? How can I add one?
- chad July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
Answers• Can you show me how to write a meta-class that will allow fixed named methods to be invoked before and after a method in an instance of that class is invoked?
- chad July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
AnswersWhat does it mean for two classes to have a different type erasure?
- chad July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 0of 0 votes
AnswersWhat is the drawback for string type in Java . suppose you have to deal with millions of strings and u need to save them , how will you save them . imagine there is not enough space to save those strings . This is Big data related question . interviewer was just interested in knowing trick to save strings .
- chad July 06, 2012 in United States| Report Duplicate | Flag | PURGE
Software Engineer / Developer Java - 0of 0 votes
Answers
- sujita July 04, 2012 in India for noida1.Design a vending machine in java.takes coins of 2,3,7,JAVA 2.Design one/two player tic-tac-toe,Java. 3.sort array {0,1,1,0,1,0,1,0,0,1,1,1,0} of binary numbers in O(n) time complexity using property of binary numbers.(no counting here) 4.Design/implement a Hashset class of your own. 5.Memory dumps in java ....................................................................................
| Report Duplicate | Flag | PURGE
Oracle Site Reliability Engineer Java - 0of 0 votes
Answersreverse a string
- Vk June 29, 2012 in United States
"hello my name is" to be displayed as "is name my hello"| Report Duplicate | Flag | PURGE
Labs247 Quality Assurance Engineer Java - 0of 0 votes
Answersfind the no. of time a particular word is occurring in a string?
- Vk June 29, 2012 in India
eg. "Hello I am going to I with Hello am"?| Report Duplicate | Flag | PURGE
Labs247 Quality Assurance Engineer Java - 0of 0 votes
AnswersI have given a Long Sentence and some words(to be searched in the sentence), i have to find the smallest part of the sentence which contains all the words to be Searched in that Sentence and print that part.
I have tried it, 1. First get all locations(indexes) of all words from the given sentence. 2. then try to find smallest part from these indexes of words.
But i am having problem implementing 2nd part . So i want some advice for it or if you suggest any other algorithm which can make it fast.
Example: If i have a String > "Hello, my name is undefined. but your name is not undefined." and i have to search word [is, undefined] then the answer should be printed is: is undefined //which is taken from the sentence 1st and we can not print from second sentence as it is " is not undefined" because it is not shortest.import java.util.*; import java.io.*; public class ShotestSubSegment2 { static SearchStr[] search; static String copystr; public static void main(String s[]) { try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = in.readLine(); copystr = str.substring(0).toLowerCase(); int k = Integer.parseInt(in.readLine()); search = new SearchStr[k]; for(int i=0;i<k;i++) { search[i] = new SearchStr(in.readLine().toLowerCase()); getIndicesOf(search[i]); if(search[i].noOfElements()==0) { System.out.println("No Segments Found"); return; } } searchSmallestPart();//Dont getting Idea Of this } catch(Exception x){} } public static void getIndicesOf(SearchStr searchS) { String searchStr = searchS.getName(); int startIndex = 0, searchStrLen=0; int index; searchStr = searchStr.toLowerCase(); searchStrLen = searchStr.length(); while ((index = copystr.indexOf(searchStr, startIndex)) > -1) { searchS.add(index); startIndex = index + searchStrLen; } }
}
- newhere June 27, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Java - 0of 0 votes
AnswersA very interesting question. Still awaiting answer so posting again.
What does this method do? Stuff is a object in java with two members someStuff and anotherStuff public static Stuff doSomeStuff (Stuff s0, Stuff s1) { Stuff someStuff = s1.getSomeStuff(); if(someStuff != null){ s1.setSomeStuff(doSomeStuff(null, someStuff)); } if(s1.getAnotherStuff()==null){ s1.setAnotherStuff(s0); return s1; } else { Stuff myStuff = doSomeStuff(s1,s1.getAnotherStuff()); s1.setAnotherStuff(s0); return myStuff; } }
Does it have any bugs or edge cases where it will not execute?
- chaos June 22, 2012 in United States
Describe the time complexity of the function and comment on its effectiveness.| Report Duplicate | Flag | PURGE
Amazon Java - 0of 0 votes
AnswersCan you implement a java application without Abstraction?
- pratibha84.s June 20, 2012 in India| Report Duplicate | Flag | PURGE
Sabre Holdings Software Engineer / Developer Java - 0of 0 votes
AnswersWhat is the difference when ArrayList is synchronized and used with respect to vector is there any difference?
- for.forums.java June 20, 2012 in India
Focus point is both will be in synchronized state whats happens internally.| Report Duplicate | Flag | PURGE
Pega Applications Developer Java - 0of 0 votes
Answersi was asked the following question and they need java solution for it.
- dev June 17, 2012 in India
Checkers is an ancient board game played by two players, traditionally called 'Black' and 'White'. It is played by turns on an 8x8 board, which has alternating black and white squares. All the pieces are placed on black squares only and move in a diagonal fashion, i.e., a piece cannot move vertically or horizontally, but only diagonally.
When it is a player's turn, he can either make a move or a sequence of jumps. A jump is defined as a diagonal move over exactly one piece of the opposing colour. The piece that has been jumped over is said to be captured, i.e., it is removed from the board. The players try to capture as many of the opponent's pieces as possible and the game ends when all the pieces of any one player are captured.
Checkers rule states that the white piece (A) has a choice of moving to his left, or jumping over the black piece. Since the intent of the game is to capture as many of the opponent's pieces as possible, White should choose 'A' to jump over the black piece. After jumping, 'A' reaches a square from which he can jump further, either left or right. The jump to the left is better because it allows White to make one more jump, unlike the jump to the right, which leads to no more jumps. The white piece (, in the figure, can only move and not jump. Thus, according to the figure, White can jump thrice in one turn, using 'A' or alternatively can move once using 'B'. Obviously, the better choice is jumping with A.
You have to write a program which, given a board configuration, calculates the maximum number of jumps possible in one turn, by any White piece. Given the board above, the program would output '3'.
Notes:
It is illegal to jump over a piece of your own colour.
A player's turn is complete when he makes either a move or a sequence of jumps.
A jump can land only on an empty square.
Input specification:
The input will consist of eight (8) lines of eight (8) characters each. The characters will be one of the set {B, W, ~, #}.
� B => Black piece
� W => White piece
� ~ => An empty black square
� # => White square. Note that a piece can never land on a white square
Output specification:
Your program has to output the maximum number of jumps that can be made by any of the white pieces. If white cannot make any jump at all, then your program must print the integer '0' (zero)
Sample Input and Output:
Input:
#B#~#B#~
B#B#B#B#
#~#~#~#~
~#B#~#~#
#~#W#~#~
~#~#~#~#
#W#W#W#~
W#W#W#W#
Output:
4
Input:
~#~#~#~#
#B#B#B#B
~#~#~#~#
#B#B#~#~
~#~#~#~#
#~#B#~#~
~#W#W#W#
#W#W#W#W
Output:
5| Report Duplicate | Flag | PURGE
CDAC-ACTS Computer Scientist Java - 0of 0 votes
AnswersHow do you delare a constant in java..other that using final keyword..
- shine June 14, 2012 in India
example, how will you create a constant StringBuffer??? What does using final mean in this case - it doesn't make StringBuffer constant..| Report Duplicate | Flag | PURGE
Informatica Software Engineer / Developer Java - 0of 0 votes
AnswersWhy do we use volatile? it doesn't ensure atomicity?
- shine June 14, 2012 in India
How is volatile used for objects?
How do you synchronize an object across all instances (static synchronization)| Report Duplicate | Flag | PURGE
Informatica Software Engineer / Developer Java - 0of 0 votes
AnswersWhy are static inner class used in the design? Are they really needed?
- shine June 14, 2012 in India| Report Duplicate | Flag | PURGE
Informatica Software Engineer / Developer Java