• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Late Binding

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
class Base
{
void methodA()
{
System.out.println("base - MethodA");
}

}
class TestBinding extends Base
{
public void methodA()
{
System.out.println("sub - MethodA");
}

public void methodB()
{
System.out.println("sub - MethodB");
}

public static void main(String args[])
{
Base b=new TestBinding(); //1
b.methodA(); //2
b.methodB(); //3
}
}
There is a compile error at //3. (cannot resolve symbol) Can anybody explain what that mean? methodB is available as one of the members of TestBinding class. I am not sure why it will cause compile error.
Thanks
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here case is OverRidding Method :
OverRidding method take place as follow sequesnce :
1. see in ref type whether method def. is there or not.
2.if method is there in base class then it will look
in sbclass type for that method and if it is there(overridden)
it will executed otherwise inherited method in subclass
is executed.
in your case there is no mehtod is there refer at line 3.
so compiler complaint at compile time.

 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jariwala_b
Please read the Javaranch Naming Policy and register again.
Thank you for your cooperation

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Did you miss me? Did you miss this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic