Java Virtual Machine Flashcards
Java compilers start with Java source code and create class files containing what type of code?
Java Byte Code.
(T/F) When a Java program is executed, the byte code class file is either interpreted or compiled, or both.
True.
Are there other languages that can compile Java byte code? If so, what is the advantage?
Yes. Scala is an example. (Most of Twitter uses Scala).
The advantage is that it allows them to be architecture independent.
Is JVM a stack based architecture or register based?
Stack Based.
What is a Java Class File?
A stream of 8-bit bytes consisting of a single ClassFile structure.
There is a C structure to define what it is.
In JVM, loads and stores are between the memory and…
The Stack.
In the JVM, arithmetic operations get their operands from the stack and leave their results where?
Back on the stack.
A JVM instruction consists of one-byte opcode that specifies the operation to be performed. How many arguments can an opcode have?
Zero or more.
Give an example of a JVM inner loop.
In JVM, variables are typed. Primitive types are assigned a one letter type code. For example, integers are identified by I. Class names use what letter?
L followed by a fully qualified name.
What are some examples of the JVM type definitions?
In JVM, method signatures are indicated by a ‘(‘. What are some examples of method signatures definition in JVM?
What are JVM’s three kinds of variables?
- Static members of a class
- Non-Static members of a class
- Local variables in methods
Static Members of a Class
When using ‘getstatic’ and ‘putstatic’ to push or pop a static variable on the stack, what information is required?
- Classname
- Fieldname
- Type
Non-Static Members of a Class
In JVM, ‘getfield’ and ‘putfield’ require the classname, fieldname, and type to be provided when pushing and popping fields. Since a class can have multiple instances of a field, what else is required?
The reference to the object.
Local Variables in a Class are stored in method frames. These frames get created when methods are called and it includes an operand stack. The local variables (parameters and declared locally) are stored in what type of data structure?
The local variables are stored in an array and accessed by index number.
What instruction is used to load integer/boolean local variables to the top of the stack and remove them from the top of the stack?
- iload
- istore