Thursday, 3 April 2014

Final Method


Final Method:
class Parent {
  public  void show()
{
System.out.println("parent ");

}


}

class Child extends Parent {
public final void show()
{
System.out.println("child ");

}
public static void main(String[] args)
{
Child c=new Child();
c.show();
Parent pc=new Child();
pc.show();



}

}


method overridding:

final-----------final   not possible
final-----------non final not possible
non final-------final possible


final methods are object type but not reference type.



Best Tutorial  :
click here:

Javatpoint - A Solution of all Technology


No comments:

Post a Comment