asked 94.8k views
4 votes
What objects does the garbage collector of JVM collect?

1) Only those objects created using the new keyword
2) All objects in the JVM
3) Objects created without using the new keyword
4) Objects created using the finalize method

asked
User Jasuten
by
8.2k points

1 Answer

4 votes

Final answer:

The garbage collector of JVM collects all objects in the JVM, regardless of how they were created.

Step-by-step explanation:

The garbage collector of JVM (Java Virtual Machine) collects all objects in the JVM, not just those created using the new keyword or those created without using the new keyword. It also collects objects that are created using the finalize method. The garbage collector automatically identifies objects that are no longer needed and frees up the memory they occupy, improving the performance and efficiency of the program.

answered
User Sheppe
by
7.7k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.