Friday 8 January 2016

A sample from  recent round of Java interviews:

  • String questions: Check if one string is a rotation of other string, check if a string is a palindrome, check if a string is a substring of other string,  return the index of the first occurence of a substring in other string,  reverse a string, find the largest palindrome in a string
  • LinkedList questions: Reverse a linked list recursively(in-place) and iteratively, delete a node from linked list, find the nth node, find the nth node from the end, test if a linked list has a cycle, write test cases
  • What is immutable, Implement an immutable class (e.g. myDateTime)
  • What are volatile, synchronized, atomic
  • Implement a thread-safe (blocking) queue
  • What are some ways to implement a singleton in Java
  • Implement a counting semaphore
  • JVM/GC questions
  • Checked vs unchecked exceptions, finalize
  • What is a queue, stack, heap
  • Level-order BFS on a binary tree
  • Find all paths of length L in an acyclic graph
  • What happens in the system during a recursive call
  • Remove an item from an array of ints, print the second largest number in an array, remove a character from a string
  • Compute sum of Fibonacci series (recursively and iteratively)
  • Write a method receiving a stream of integers, caching the last 10 min of data and returning a number if it's less than the current input
  • Mutexes, ReadWriteLock, ConcurrentHashMap, ArrayBlockingQueue, Thread pools, LinkedList vs ArrayList, Object Pooling, Read-Modify-Write, java.util.concurrent, java.util.concurrent.atomic, CAS, Collections, ADT, Java 5 Generics
  • HashMap vs HashTable vs ConcurrentHashMap
  • Implement a regular expression matcher
  • Implement  a comparator for a string and its rotation (i.e. "test" would be equivalent to "stte")
  • Synchronous vs asynchronous, thread contention, race conditions/deadlocks and how to prevent/debug them, thread confinement, cache coherence, false sharing, cache lines
  • How would you write a socket client/server in Java
  • Java IO/NIO, socket multiplexing, blocking vs non-blocking, select/epoll
  • Sleep vs wait
  • Process vs thread, Java threads vs Pthreads, Linux threads vs Solaris threads, what happens when a process/thread is started/terminated, what happens during context switch
  • Java Memory Model, Weak references
  • Jini, JMS, Javaspaces, JGroups, Hibernate trivia
  • Java vs C/Python/Scala, OOP vs functional, OOP vs procedural, composition vs inheritance, best practices in API design
  • Abstract Class vs Interface
  • Memoization, give an example
  • Can you have a protected method in Interface
  • How to force a stop-of-the-world GC
  • What can be done to interrupt a synchronized method that is blocked
  • Java performance, heap profiling, GC tuning, thread dumps, Hotspot vs JRockit
  • Latency/clock measurements, NTP sync/drift
  • How would you implement low latency data structures
  • How would you debug performance issues, what do you do if a database query is "slow", describe the troubleshooting approach when a customer complains that the UI is "slow"
  • Deployment questions
  • Knight Tour puzzle- write a method for a knight to find another figure (a fool) on a chessboard
  • Clock puzzles - find the angle between hr,min,sec handles, etc
  • 3 jars puzzle (one jar is filled with 8 gallons, two jars are empty (capacity 5, 3), write a routine to get to 4-4 state
  • TCP handshake, RTT, definitions of bandwidth, throughput, latency
  • What happens when a browser requests an html page from a server (IP/TCP/HTTP end-to-end, describe what happens in the kernel/NIC on the sender/receiver)
  • TCP vs UDP performance, TCP congestion control, buffering, ordering, retransmission, TCP tuning, kernel bypass/zero-copy, reliable multicast
  • How do traceroute, ping, nslookup work
  • Inner join vs outer join
  • What are ACID properties in a database, explain CAP theorem
  • What is caching; How would you implement a caching server for a streaming video service (messaging/queues, data structures, expiration/eviction), handle expirations, how would you benchmark the performance of your caching  service, how do you scale it to thousands of customers, what is CDN
  • How would you design a high throughput order management system, matching engine, market data engine, FIX engine (trading)
  • What is horizontal scaling
  • How would you design a data collection service (i.e. downloading/streaming data from multiple sources from the web), distributed data feeds/CRUD data store design,indexing, performance/scalability/availability considerations
  • How would you extract a histogram of occurrences of order types from a FIX  log if the order of tags is changing (grep -o ...|sort |uniq -c)
  • What is the fastest way to do a grep on 10GB plain text file on a laptop
    with 4GB memory, what are some pre-processing techniques to speed up an
    IO-bound call, compression, regular expressions
  • Describe load average, iowait, inode, IPC, zombies, linux boot process, iostat, vmstat, kill, ps, swapping, fork/exec, process states/data structure, syslog
  • What does it mean "everything in unix is a file"
  • What happens when you type Ctrl C while executing a unix pipeline; interrupts, signals, traps
  • Describe the projects you're most proud of, the most difficult problems you've solved as an engineer, what is your favorite programming language

I've found these resources helpful:

No comments:

Post a Comment