Java Interview Questions | Glassdoor

Find jobs for Java

Java Interview Questions

2,241

Java interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

After a night of wild revelry, a group of local intoxicated hoodlums stumble into a children's playground. One of these hoodlums, Phil, climbs to the middle of a spin-around carousel and his friends push the carousel so it rotates once every five seconds. Phil, who is trying not to get sick, holds a flashlight motionless in his hand. There is a straight path running by the playground that, at its closest point, is 30 meters from the middle of the carousel. Unknown to Phil, there are two cops facing him on the path, shocked at the spectacle. One of them is standing on the path at the point closest to the carousel, while the other is standing 60 meters down the path. At approximately what speed (in meters per second) does the spot illuminated by the flashlight traverse each of the cops' bodies? State speed at the closest cop first.

2 Answers

Two developers, Ann and Suzy, are waiting for code to compile. Suzy learns that Ann's sister has three children, and asks how old they are. Ann responds, "The product of their ages is 36." Suzy says, "Oh c'mon--I can't figure it out with that!" Ann replies, "Ok, then the sum of their ages is the same as this number right here," and points to a number on the screen. Suzy says, "Nope, still can't do it," and Ann replies, "The oldest is dyslexic." How old are the children? (Order from oldest to youngest)

3 Answers

There is nothing like difficult part.

2 Answers

how to find square root of integer

3 Answers

why C++ deconstructor defined as virtual

2 Answers

3. Trees (binary and otherwise) form the basis of many common data structures. Please describe some of these data structures and when they might be used.

2 Answers

5. The user of this class expected the output “Num: 1000000”. They got something else. What went wrong and how would you fix it? public class Test { public final static int NUMTHREADS = 1000; public final static int NUMLOOP = 1000; public static int num = 0; static class Mythread extends Thread { @Override public void run() { for (int i = 0; i < NUMLOOP; i++) { ++num; } } } public static void main(String argv[]) { Mythread threads[] = new Mythread[NUMTHREADS]; for (int i = 0; i < NUMTHREADS; ++i) { threads[i] = new Mythread(); threads[i].start(); } try { for (int i = 0; i < NUMTHREADS; ++i) { threads[i].join(); } } catch (InterruptedException e) { } System.out.println("Num: " + num); } }

2 Answers

How to find the median number out of 4 byte integers?

2 Answers

The program they had me debug had many files and took a while to find it. Involved a depricated class.

3 Answers

When you had an interpersonal conflict with someone, how did you handle it.

1 Answer
2130 of 2,241 Interview Questions