Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. class FinalExample{
  2. public static void main(String[] args){
  3. final int x=100;
  4. x=200;//Compile Time Error
  5. }}
  6.  
  7. class FinallyExample{
  8. public static void main(String[] args){
  9. try{
  10. int x=300;
  11. }catch(Exception e){System.out.println(e);}
  12. finally{System.out.println("finally block is executed");}
  13. }}
  14.  
  15. class FinalizeExample{
  16. public void finalize(){System.out.println("finalize called");}
  17. public static void main(String[] args){
  18. FinalizeExample f1=new FinalizeExample();
  19. FinalizeExample f2=new FinalizeExample();
  20. f1=null;
  21. f2=null;
  22. System.gc();
  23. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement