Whether a Class,Method can be garbage collected or not?How?

Showing Answers 1 - 7 of 7 Answers

sarat

  • Sep 29th, 2005
 

hi,

class is structure,method is  a part of that one only,no one doesnt erase the claass, only its instance only.

  Was this answer useful?  Yes

Devidas Sonawane

  • Oct 25th, 2005
 

Class is a programme means set of instructions and method is part of that class whichever is available in. That's why classes and methods are not garbage collected. but it's instance is garbage collected.

  Was this answer useful?  Yes

well according to me objects are garbage collected (i mean memory allocated is let free)..... therefore i think methods/classes can't be garbage collected.......

vinny

  Was this answer useful?  Yes

sayedcert

  • Jun 3rd, 2008
 

No a Clas, Methos cannot be Garbage collected simply because a class or Methoed does not have physical exestence in memory and garbage collector is only used for freeing up the memory which only applies to objects not classes or methods.So only objects can considered for garbage collection not  classes or methods..

  Was this answer useful?  Yes

sayedcert

  • Jun 3rd, 2008
 

No a Class, Method cannot be Garbage collected simply because a class or Method does not have physical exestence in memory and garbage collector is only used for freeing up the memory which only applies to objects not classes or methods.So only objects can considered for garbage collection not  classes or methods..

  Was this answer useful?  Yes

No. Class and methods aren't garbage collected.
Because Class is a logical construct in that we write methods or logics.
When we run Java program, class gets loaded in main memory that is RAM and methods gets loaded on stack.
When we create objects / instance of a class, memory is allocated on the heap for that object. When the program terminates the JVM calls the GC (Garbage Collection) to destroy the objects. We can't guarantee that when JVM invokes the GC.
Only objects are eligible for GC no classes and methods...

Umesh Kilkile

  Was this answer useful?  Yes

MMK143

  • Mar 28th, 2010
 

Class and Method are not garbage collected because class and methods are the predefined instruction formats for developing an object oriented programming.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions