JVM Specification interview questions. Part 1: the JVM Structure

Egor
2 min readApr 14, 2017

--

Hi there.

I’ve decided to refresh my knowledge and read the JVM and Java Language specs (SE 8) one more time. I will post a bunch of questions and answers on each chapter in a series of Medium posts.

The first one is for the Chapter 2: The Structure of the JVM

  1. What happens if the thread stack reached it’s maximum?
  2. How many stacks may each thread have?
  3. In which case number in JVM would not be equal to itself?
  4. Where is the method area memory allocated?
  5. What is the first value in a frame runtime variables array?
  6. What would the ‘aclone’ bytecode instruction mean if it ever existed?
  7. What amount of memory is allocated for each boolean in the JVM?
  8. Name the difference between the asynchronous and synchronous exceptions in the JVM.
  9. What does an ACC_SYNCHRONIZED flag in a method constant pool mean?
  1. Three things may happen. If the stack in the current JVM implementation can dynamically grow it will grow (1) as long as there is a memory to allocate. If there is no more memory the OutOfMemoryError will be thrown (2). If the stack has a constant size a StackOverflowError will be thrown (3).
  2. Two. One for the JVM bytecode another for the native methods.
  3. In case it is a floating point number and its value is NaN.
  4. In heap.
  5. The reference to the current object (this).
  6. ‘a’ mnemonic stands for an Object, hence it would clone an object.
  7. 1 byte.
  8. Synchronous errors are thrown from inside the thread not interrupting a running instruction. Asynchronous ones may be thrown outside the thread and may stop the instruction execution.
  9. It does mean the method is marked with a synchronized keyword and is protected by a monitor.

Your commentaries are extremely welcome!

--

--