Friday, 19 January 2024

final , finally and finalize

  •  What does "final" refer to?
    • For variables, it ensures that the value remains constant
    • For methods, it prevents methods from overriding
    • For class, it prevents extending the class
  •  What does "finally" refer to?
    • It is part of try-catch-finally block statements
    • It is used to define a block of code whether an exception throw or not
    • It ensures that certain actions are taken regardless of the outcome of try block
  •  What does "finalize" refer to?
    • It is a special method part of the object class
    • It is called by the garbage collector before an object is reclaimed
    • It is called before the memory occupied by the object is freed up
    • It allows an object to clean operations before it is garbage-collected

No comments:

Post a Comment

Reverse Words in a Sentence