Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

a small problem related to abstract classes

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in an abstract class, for an abstract method, why can not we provide 'private' access modifier to the abstract method....

abstract class Car{
private abstract void method(); // why this is leading to compile time error??
} // whereas 'protected' and default access do not result errors...

please resolve this.....
thanks in advance!!
 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you declare a method abstract it means the method must be implemented. Private methods can't, that's why it generates the the compile error.
 
shubham garg
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got it. thankx eduardo bueno!!
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
interface's methods are implicitly:
public abstract
interface's variables are implicitly:
public static final
You cannot change it.
 
author
Posts: 23919
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lukas Sieradzki wrote:interface's methods are implicitly:
public abstract
interface's variables are implicitly:
public static final
You cannot change it.



Interesting points... but this topic is not about interfaces.

Henry
 
Lukas Sieradzki
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Lukas Sieradzki wrote:interface's methods are implicitly:
public abstract
interface's variables are implicitly:
public static final
You cannot change it.



Interesting points... but this topic is not about interfaces.

Henry


You are right but private is not public so I typed that modifiers for methods and variables in the interface cannot be changed. This is my explanation. The second explanation was also provided. private can't go with abstract because overriding won't be possible.
 
shubham garg
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You are right but private is not public so I typed that modifiers for methods and variables in the interface cannot be changed. This is my explanation. The second explanation was also provided. private can't go with abstract because overriding won't be possible.

i think this xplanation is out of context because in the problem there is no interface... the code is of an abstract class not an interface actually...
 
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic