1.
final
method:-
final
method are the java methods, they are not allowing method overriding.
Note :-
To perform method overriding, we have to declare method at
super class and sub class with the same prototype and with different
implementation part. In method overriding super class method never be declare
as “final”, but, we many declare sub class method as final.
Ex 1:-
class A
{
final
void m1()
{
-----
}
}
class B extends A
{
void
m1()
{
------
}
}
Status :-
Compilation Error
Ex 2:-
class A
{
final
void m1()
{
-----
}
}
class B extends A
{
final
void m1()
{
------
}
}
Status :-
Compilation Error
Ex 3:-
class A
{
void
m1()
{
-----
}
}
class B extends A
{
final
void m1()
{
------
}
}
Status :-
Compilation Error
No comments:
Post a Comment