Answer Posted / ashwani maddeshiya
static void gc() // Requests GC to run
static void runFinalization() // Requests finalizers to run
OR
mport java.util.*;
class GarbageCollectionDemo
{
public static void main(String s[]) throws Exception
{
// Get runtime environment
Runtime rt = Runtime.getRuntime();
System.out.println("Free memory before Garbage Collection = "+rt.freeMemory());
// Apply garbage collection
rt.gc();
System.out.println("Free memory after Garbage Collection = "+rt.freeMemory());
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
When would you use a static class?
What does it mean that a method or field is “static”?
Why is multiple inheritance not supported in java?
What happens when a thread cannot acquire a lock on an object in java programming?
What is the difference between stringbuffer and stringbuilder class?
Why there are some null interface in JAVA? What does it mean? Give some null interface in JAVA?
Explain try and catch keywords in java?
Explain about version control?
What is singleton class example?
What are the different types of constructor?
What is the difference between static and global variables and also define what are volatile variables?
What are controls and their different types in awt?
Why string is not a wrapper class?
What is java lang object?
What is string array?