Why we need to create object for final class and what are its benefits?

Questions by sitaramb

Showing Answers 1 - 9 of 9 Answers

sunny jain

  • Dec 25th, 2014
 

we can not create the object of final class.

  Was this answer useful?  Yes

Bimal Modak

  • Jan 14th, 2015
 

We can create the object of final class and this will act like any simple object created for simple class.

Code
  1.  

  2. public final class BlockTest {

  3.   public void testMethod(){

  4.     System.out.println("inside test method.");

  5.   }

  6.   public static void main(String[] args) {

  7.     BlockTest bt = new BlockTest();

  8.     bt.testMethod();

  9.   }

  10. }

  11.  

  Was this answer useful?  Yes

Ahmed reda

  • Jun 29th, 2015
 

A final class cannot have any subclasses. This just means that nobody can create a subclass that modifies behaviour of the final class by modifying internal data or overriding methods so they behave differently. A good example is java.lang.String; by making it final, it is ensured that String objects are and always will be immutable.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions