Java Developer Interview Questions
- 0of 0 votes
Answerin a web request you want to send results to the browser/client only if the caching operation goes success. how do you accomplish this.
- cheeta May 14, 2014 in United States| Report Duplicate | Flag | PURGE
Citigroup Java Developer Java - 0of 0 votes
AnswersI have been asked this question in written test. which pattern to use..
- vishal April 26, 2014 in India
Using Java create a simulation of a car park. The
program will record vehicles entering and exiting the car
park, as well as the total balance of parking fees paid.
Cars can park in the car park for $2 per hour.
Trucks can park in the car park for $3 per hour.
For example a car parked for 2 hours will pay $4
and a truck parked for 2 hours will pay $6.
The program can also be asked for a balance report that
will show how many vehicles have entered and exited,
the number of spaces available and how much money has
been paid so far.
Trucks take up 2 car spaces.
The requirements for the interface:
1. The user records vehicles entering and exiting the
car park.
2. Upon exiting the car park a time in whole hours
spent in the car park is also entered.
3. The user can request a balance report of the car park
at any time.
4. The program can be exited at any time.
5. The program should validate user input.
Provide a production ready solution including source
files, project structure and any testing you have used.
Example #1
--------------------------------------------------
Program: How many spaces does the car park have?
User: 10
User: ENTER CAR
User: ENTER TRUCK
User: REPORT
Program:
Cars Entered: 1
Trucks Entered: 1
Cars Exited: 0
Trucks Exited: 0
Parking Cars: 1
Parking Trucks: 1
Spaces available: 7
Fees paid: $0
User: QUIT
Example #2
--------------------------------------------------
Program: How many spaces does the car park have?
User: 15
User: ENTER CAR
User: ENTER TRUCK
User: EXIT CAR 2
User: REPORT
Program:
Cars Entered: 1
Trucks Entered: 1
Cars Exited: 1
Trucks Exited: 0
Parking Cars: 0
Parking Trucks: 1
Spaces available: 13
Fees paid: $4
User: QUIT| Report Duplicate | Flag | PURGE
Accenture Java Developer - 0of 0 votes
AnswersGiven three strings a, b, c. Write a function to find the smallest subsequence in a, which contains all the characters from b but none from c.
- Green April 26, 2014 in India for Machine coding
* b and c are mutually exclusive.| Report Duplicate | Flag | PURGE
Flipkart Java Developer Coding - 0of 0 votes
AnswersCreate a Employee Database for an organization. Each employee may or may not have a manager. One employee may have many subordinates. This can grow upto any level.
- Green April 26, 2014 in India for Machine coding
* Find all the subordinates for a given employee.
* Find the manager details of an employee.
Assumptions:
* Employee contains
ID: int (Unique)
Name: string
Designation: string
Email: string
* One employee can have only one manager.
* All the information is in-memory. No database needed.| Report Duplicate | Flag | PURGE
Flipkart Java Developer Coding - 1of 1 vote
AnswersGiven three strings str1, str2 and str3; complete the function to find the smallest subsequence in str1 which contains all the characters in str2 (in any order) and not those in str3.
- ankur.emailid April 21, 2014 in India
Sample Test Case:
Sample Input:
str1: spqrstrupvqw
str2: sprt
str3: q
Sample Output: strup
Explanation: In the given string str1, the smallest subsequence that contains the characters in str2 ( 's' , 'p' , 'r' , 't' ) and does not contain the character in str3 ( 'q' ) is 'strup'.| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer String Manipulation - 23of 23 votes
AnswersYou have a complete graph with N vertices. You know that all edges have a cost of A and you are given a set of K edges whose cost is B. Find the shortest (cheapest) path from node 0 to node N - 1.
- f.v.anton April 12, 2014
0 < N, K < 500k
1 < A, B < 500k| Report Duplicate | Flag | PURGE
Java Developer Algorithm - 0of 0 votes
AnswersAmazon is considering introducing a customer loyalty program, which rewards members with Amazon Dollars on purchases. The program encourages members to be sponsors and recruit other shoppers to join. Purchases made by recruits are then rewarded to the sponsor. The chain of recruits can be arbitrarily deep. Any purchase by a member is counted towards that member (10% of purchase price), their sponsor (4%), their sponsor’s sponsor (4% of 4%), their sponsor’s sponsor’s sponsor (4% of 4% of 4%), etc. Finally, a sponsor can have any number of recruits, but any one recruit can only have one sponsor.
- kdaryani@hawk.iit.edu April 04, 2014 in United States
Write a function that calculates the payout for a given member.
Given the following interface, please implement the MemberPayoutUtil.calculatePayout function.
public interface Member {
public double getMonthlyAmazonDollars();
public Collection<Member> getRecruitedMembers();
}| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
AnswersWe can start a Thread using either of two methods start() and run().What is the difference between these two?
- searchingviswa March 15, 2014 in India for 100| Report Duplicate | Flag | PURGE
JP Morgan Java Developer Java - -1of 1 vote
AnswersThere is a string , where a character is missing.Print the missing character.The range is present in the string and the characters are case sensitive.
- write2bikash February 19, 2014 in India
For example:-If input is "baADfc".
Here the range is a to f.
The missing character to be printed is e.
.| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Coding - 0of 0 votes
Answersi have an array{{1,2,3},{4,5,6},{7,8,9}}.I want output=1,2,4,3,5,7,6,8,9
- chaudharyklbsimds January 29, 2014 in India| Report Duplicate | Flag | PURGE
Java Developer - 0of 0 votes
Answersi have 2 class class employee which has empname and Title(manager,team lead) and class person which has name age and gender.. now i need to create a hasmap which has key and value pair as employee and person and if i give employee as key it should give me person values and if i give person as key it should give me employee value
- sandesh udupi January 26, 2014 in India| Report Duplicate | Flag | PURGE
Java Developer Java - 0of 0 votes
AnswersPlease suggest best algorithm for following scenario:
- Ankush Sood January 24, 2014 in India
We have two ArrayList containing Integer values, Both are unordered, have repeating elements and contains thousands of Integer objects.
Example : L1 - 2,4,1,1,6,4,3,1.... and so on
: L2 - 9,2,1,2,1,23,34,.. and so on
Both list contains large amount of data.
We need to get List of non repeating elements from both of them. For example consider L1 and L2 output list should contain 9, 3 23,34 as remaining elements are available in both lists.| Report Duplicate | Flag | PURGE
Java Developer Algorithm - 0of 0 votes
Answerswrite Fibonacci series with recursion.
- contacttovimal January 11, 2014 in India for Risk Management/CMOT| Report Duplicate | Flag | PURGE
Citigroup Java Developer Coding - -1of 1 vote
Answershow you will design directory so your search will faster, provide solution so my search time is efficient.
- contacttovimal January 11, 2014 in India for Risk Management/CMOT| Report Duplicate | Flag | PURGE
Citigroup Java Developer Coding - 1of 1 vote
Answersyou have array of n size having numbers between 1 to 100. you need to provide algorithm for sorting array with BigO(n) iteration.
- contacttovimal January 11, 2014 in India for Risk Management/CMOT| Report Duplicate | Flag | PURGE
Citigroup Java Developer Algorithm - -2of 2 votes
Answersclass NoName { children = new Hashtable() name = "" boolean hasChild(child: string) { return this.children.hasKey(child) } NoName addChild(child: string) { var childnode = new NoName() childnode.name = child this.children[child] = childnode return childnode } NoName getNode(child: string) { if this.hasChild(child) return this.children[child] else return this.addChild(child) } void addList(input: string) { var currentNode = this.getNode(input[0]) input = input.SubString(1, input.Length ? 1) if (input.Length < 1) currentNode.getNode("") else currentNode.addList(input) } string scan() { if (this.children.Values.Length == 0) return this.name if (this.children.Values.Length == 1) return this.name + this.children.Values[0].scan() var temp = new Array() foreach(child in this.children.Values) temp.Add(child.scan()) return this.name + "{" + temp.Sorted().JoinArray(",") + "}" } } var x = new NoName() x.addList(’/home/user/foo’) x.addList(’/home/user/bar’) x.addList(’/home/user/baz/one’) x.addList(’/home/user/baz/two’) print x.scan()
Is there anyone can help me translate these code to java or tell me the result ,I will really appreciate it.Thanks
- miller9977 January 10, 2014 in United States| Report Duplicate | Flag | PURGE
Hewlett Packard Java Developer Coding - 0of 0 votes
AnswersImplement entity tag cache in following two assignments. Design cache for
- gzagarwal January 08, 2014 in United States
read performance. Also, ensure that it takes as little memory as possible.
Write a caching class EntityTagCache that is supposed to cache tags for a given
id. Also provide TestEntityTagCache JUnit class that we can use to verify the
functionality. We only need above two files ( e.g. no need for build file ), as
we'll go through your solution in an Eclipse Java project.
An entity and its tags have following characteristics:
- A given entity is identified by an int id. The id is >= 0.
- An entity can have 0-N tags, where each tag is a string value. E.g. for
id '1', we can have tags like 'foo' & 'bar'. There are around 1000 unique
tags in 100 million entities, but the actual number can vary by a few thousand.
- The EntityTagCache does not need to consider id/tag eviction. It is expected
for the cache to throw a OutOfMemoryError if more tags exist than we can cache
in memory. However, the design should ensure that it takes as little memory
as possible to cache the tags.
- There can be maximum of 100 million entities in the cache and the id value
cannot be more than the number of entities in the cache and is >= 0. Thus,
if we've to cache 100 entities, then id is from 0 to 99.
- We should be able to load our initial data into the cache when we create
EntityTagCache. We should pass a file to the cache that contains entity
information. E.g.
entities.csv
------------
1,foo,bar
2,abc,foo
3
4,xyz,bar
In above, in first line entity id is 1 and tags are foo, and bar. For entity id 3
there are no tags.There are four unique tags 'foo', 'bar', 'abc', and 'xyz'.
EntityTagCache cannot be updated once it has all the data. Also, it
does not need to have any notion of eviction, as we require that all the
data must be loaded in memory. The cache only provides the following
public method:
1. 'getTags' method that takes an id and returns the tags for the entity.
This method on worst case ( barring garbage collection) take a few
100 nano seconds. It can be called 1000's of time in a few milliseconds.
The cache should be designed for multi threaded access with 1000's
of requests to getTags in a few ms.| Report Duplicate | Flag | PURGE
Oracle Java Developer - -5of 5 votes
AnswerMinimum Spanning Tree using alghoritm prim
- fgfsdgs January 06, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Java Developer - -2of 2 votes
Answersprim algorithm determine Minimum Spanning Tree java?help code java
- fgfsdgs January 03, 2014 in United States| Report Duplicate | Flag | PURGE
AMD Java Developer Algorithm - -1of 1 vote
AnswersTwo array with integers.Find the value in both of them with out using set.Find the time complexity?
- HadoopUser December 28, 2013 in India| Report Duplicate | Flag | PURGE
Expedia Java Developer Data Structures - 0of 0 votes
AnswersA String is given ilke--abdecadc...szx..any thing..like this...element in this given pattern can be any this(like int also and letter till z also)
- amit.grynch December 28, 2013 in India
you have to arrange in pattern--aabbcclike....ie.same charactor together...| Report Duplicate | Flag | PURGE
EMC Java Developer Java - 0of 0 votes
Answerspublic static LinkedList reverse(LinkedList current)
- jackiewu09 December 05, 2013 in United States
{
LinkedList result=null;
if(current==null) return null;
if(current.next==null) return current;
//LinkedList current=head;
LinkedList prev=null;
LinkedList next=current.next;
while(current!=null)
{
next=current.next;
current.next=prev;
prev=current;
current=next;
}
result=prev;
return result;
}| Report Duplicate | Flag | PURGE
Amazon Java Developer - -2of 2 votes
Answerswhat is green thread in java..??
- s.sameer2606 December 05, 2013 in India| Report Duplicate | Flag | PURGE
Igate Java Developer Java - 1of 1 vote
AnswersGiven a list of ranges as input ((1,2),(3,4),(3,6),(8,10)),the output would be those ranges that don't overlap.For example, the output could be merging the ranges 1) (1,2),(3,4)
- aifra2000 December 02, 2013 in United States
2) (1,2) (3,6) etc
The output cannot contain (3,4),(3,6) as 3 is common to both| Report Duplicate | Flag | PURGE
Amazon Java Developer Java - 0of 0 votes
Answersquicksort using divide and counquer . Need code please java
- fgfsdgs November 18, 2013 in United States| Report Duplicate | Flag | PURGE
Infosys Java Developer Java - 5of 5 votes
Answerswhy strings are immutable ?
- tare.rohan November 11, 2013 in India
how many objects will be created in
String temp = "A" + "B" + "C" ;
explain your answer in detail.| Report Duplicate | Flag | PURGE
Goldman Sachs Java Developer Java - 0of 0 votes
AnswersWrite a 10 digit number in such a way that the 1st digit will describes the no. of occurrence of 1, 2nd digit , no. of occurrence of 2 and so on 9th digit, the no. of occurrence of 9 in the 10 digit number.
- anilsk89 November 08, 2013 in India| Report Duplicate | Flag | PURGE
MAQ Java Developer Problem Solving - -1of 1 vote
Answerconsider 3 entity and show-
- supti.islam34 November 06, 2013 in Bangladesh
1.they are association,table representation,class interpretation using java| Report Duplicate | Flag | PURGE
Java Developer