________ exception must be either caught or specified in
throws class of the method.
Explain the differences between public, private, protected and static?
What is the purpose of extern variable?
Difference between final and effectively final ?
Are strings immutable in java?
What is the difference between private & public & friendly classes?
What are computer functions?
What is the purpose of the file class in java programming?
what is java
What is the purpose of a volatile variable?
Why we do exception handling in java and how many types of exceptions are there?
public class Garbage { int a=0; public void add() { int c=10+20; System.out.println(c); System.out.println(a); } public static void main(String args[]) { Garbage obj=new Garbage(); System.gc(); System.out.println("Garbage Collected"); obj.add(); } } Above is a code in java used for garbage collection. object obj has been created for the class Garbage and system.gc method is called. Then using that object add method is called.System.gc method if called the obj should be garbage collected?
What is the purpose of garbage collection in java?