G
G
gleendo2016-12-28 17:22:30
Java
gleendo, 2016-12-28 17:22:30

Where will the data reside in memory?

I watched a lecture about memory in java. It's time to take the tests. I opened it and I can't get it. During the lecture, everything was clear, but now I did not answer correctly any of the first 10 questions, even at random lol.
Explain at least one question. Where will they still be? And why?
21839b77767641b99a525196ca51f16d.pngQuestion: In what part of memory will the numbers 0 and 1 be located?

public class App {
    void f() {
        Holder[][] i = {{new Holder(10, 0)}, {new Holder(1, 10)}};
    }
}

class Holder {
    int i;
    static int j;
    
    public Holder(int i, int j) {
        this.i = i;
        this.j = j;
    }
}

Answer options:
  • None of the above (correct answer)
  • Neighbors in stack
  • Arbitrary in PermGen
  • Arbitrary in stack
  • Arbitrary in heap
  • Neighbors in PermGen
  • Neighbors in the heap

And how to understand adjacent/arbitrary in heap/stack?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Ray, 2017-01-06
@firezhek

References to objects are stored on the stack, objects themselves on the heap, primitives if they are local variables on the stack. You can forget about the perm gene :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question