4 B. Designed a class that demonstrates the use of constructor and destructor.
Program:
public class Prac4b
{
public Prac4b()
{ System.out.println("Hello"); }
public void finalize()
{ System.out.println("Destroyed"); }
public static void main(String[] args)
{
Prac4b obj=new Prac4b();
obj=null;
System.gc();
}
}
Comments
Post a Comment