Monday, January 23, 2012

in final class

/*
RULE: if we declared a class as final that means in that class all the methods are by default final but variables are not final
And it can not support the inheritance concept. and run time polymorphism But it can support the static polymorphism
*/

public final class Final_Class
{
int x=10;
public void method1()
{
System.out.println(x);
x=20;
System.out.println(x);
}
public void method1(int x)
{
this.x=x;
System.out.println(x);
}
}
class Demo extends Final_Class
{
public void method1()
{
System.out.println("child");
}
}