• Post Reply Bookmark Topic Watch Topic
  • New Topic

accessing parent class method using child class object  RSS feed

 
kamal walia
Greenhorn
Posts: 3
C++ Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, I want to know is there any way we can call parent class method using child class object without using super keyword in class B in the following program like we can do in c++ by using scoop resolution operator
 
Knute Snortum
Sheriff
Posts: 4276
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch, kamal.

When you post code, be sure to UseCodeTags (← click). It makes it much easier to understand your code. I've do it for you this time.
 
kamal walia
Greenhorn
Posts: 3
C++ Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well thanks a lot now i will do just like that
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beware of thinking anything about like C++. Remember C++ and Java® are two completely different languages. “It works like that in C++” is a good recipe for dangerous confusion.
Don't say parent and child: say superclass and subclass.
Don't use names like A and B for classes; that is a good way to confuse yourself, too. And what does Olor mean? It appears to be Latin for swan.

No, you have to use the super keyword.
 
kamal walia
Greenhorn
Posts: 3
C++ Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you and olor it's just a random name
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!