Java final class

Java final class

If you make any class as final, you cannot extend it.

Example of final class

  1. final class Bike{}  
  2.   
  3. class Honda1 extends Bike{  
  4.   void run(){System.out.println("running safely with 100kmph");}  
  5.     
  6.   public static void main(String args[]){  
  7.   Honda1 honda= new Honda();  
  8.   honda.run();  
  9.   }  
  10. }  
Output: Compile Time Error


Comments

Popular posts from this blog

Handling Dynamic Web Tables Using Selenium WebDriver

Verify Specific Position of an Element

Read it out for TESTNG before going for an iterview