abstract keyword:
To change the value of a const variavle, the use of pointer is done,
const int a=10;
int *p;
p=&a;
*p=20;
astract keyword used with class and method only.
final keyword used with class and method and variable
abstract class A
{
abstract int myMethod(int x); // this is the part of the signature
}
class B extends A
{
//now every child of A has to have a overridden method with the same signature int myMethod(int x), otherwise use abstract //with B also
}
Now objects of class A cant be in memory only variable and not reference variable.
The main use of abstract is to force every cild to have a method for overriding.
Final:
final int x;
x=10;
x=20; // this is not allowed
final int mymethod() {} now this method can't be overridden
final class A{} This class can't be overridden
abstract and final cannot be used simulataneously on the same thing because abstract compulsifies overriding and final keyword prohibits it.
To change the value of a const variavle, the use of pointer is done,
const int a=10;
int *p;
p=&a;
*p=20;
astract keyword used with class and method only.
final keyword used with class and method and variable
abstract class A
{
abstract int myMethod(int x); // this is the part of the signature
}
class B extends A
{
//now every child of A has to have a overridden method with the same signature int myMethod(int x), otherwise use abstract //with B also
}
Now objects of class A cant be in memory only variable and not reference variable.
The main use of abstract is to force every cild to have a method for overriding.
Final:
final int x;
x=10;
x=20; // this is not allowed
final int mymethod() {} now this method can't be overridden
final class A{} This class can't be overridden
abstract and final cannot be used simulataneously on the same thing because abstract compulsifies overriding and final keyword prohibits it.
No comments:
Post a Comment