Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
    Bookmark Topic Watch Topic
  • New Topic

final methods  RSS feed

 
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
Sheriff
Posts: 16007
87
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.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!