Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

non static method override  RSS feed

 
jignesh soni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Test{
show(int a){
System.out.println("non static show method"+ a);
}
}

public class Test1 extends Test{
static show(int i){
System.out.println("non static method overridden"+ i);
}
}

public class Tester{
public ctatic void main(String [] args){
Test t = new Test(1);
Test1 t1 = new Test1(10);
}

Can we override nonstatic method like this ?
If show() in Test is static, can we override as non static show() ?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a lot of errors to correct in that code. Once you've done this, the compiler will give you an answer.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!