OCJP Preparation - Garbage Collection - BEHIND JAVA

OCJP Preparation - Garbage Collection

Share This

Given the program

When the doSomething method is called, after which line does the Object created in line 9 become available for garbage collection?

  • A. Line 9
  • B. Line 10
  • C. Line 11
  • D. Line 12
  • E. Line 13
  • F. Line 14

Given the code

Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the object rbo?

  • A. System.gc();
  • B. Runtime.gc();
  • C. System.freeMemory();
  • D. Runtime.getRuntime().growHeap();
  • E. Runtime.getRuntime().freeMemory();

Which two are true? (Choose two.)

  • A. A finalizer may NOT be invoked explicitly.
  • B. The finalize method declared in class Object takes no action.
  • C. super.finalize() is called implicitly by any overriding finalize method.
  • D. The finalize method for a given object will be called no more than once by the garbage collector.
  • E. The order in which finalize will be called on two objects is based on the order in which the two objects became finalizable.

Given the program

When // doStuff is reached, how many objects are eligible for GC?

  • A. 0
  • B. 1
  • C. 2
  • D. Compilation fails.
  • E. It is not possible to know.
  • F. An exception is thrown at runtime.

Which is true? (Choose all that apply.)

  • A. The invocation of an object’s finalize() method is always the last thing that happens before an object is garbage collected (GCed).
  • B. When a stack variable goes out of scope it is eligible for GC.
  • C. Some reference variables live on the stack, and some live on the heap.
  • D. Only objects that have no reference variables referring to them can be eligible for GC.
  • E. It’s possible to request the GC via methods in either java.lang.Runtime or java.lang.System classes.

Given the program

At what point is only a single object eligible for GC?

  • A. After line 8 runs.
  • B. After line 9 runs.
  • C. After line 10 runs.
  • D. After line 11 runs.
  • E. Compilation fails.
  • F. Never in this program.
  • G. An exception is thrown at runtime.

3 comments:

  1. Consequently the structure of the steel garbage can fitting consummately in the secluded kitchen and rooms is the most alluring quality of the progression garbage cans.small trash cans

    ReplyDelete
  2. You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! bathroom trash can

    ReplyDelete
  3. You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! bathroom trash can

    ReplyDelete

Pages