Bookmark Topic Watch Topic
  • New Topic

final methods

 
Hasitha Randika
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Report post to moderator
--------------------------------------------------------------------------------
class A{
private final void method1(){
System.out.println("A");
}
class B extends A{
public final void method2(){
System.out.println("b");
}
}
class C{
public static void main(String ar[]){
new(B).method2();
}
}

here the answer is "b".can we override the final method in class A?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Note: If you notice, after posting, that you made a mistake, then you can edit your own post to correct it by clicking the button. You don't need to start a new post.

And please use code tags when you post code, so that the forum can display your code properly.

Continue in your other post.
 
    Bookmark Topic Watch Topic
  • New Topic