• Post Reply Bookmark Topic Watch Topic
  • New Topic

abstract class  RSS feed

 
kan ashok
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i access abstract class method return value printed in the another non abstract java class ?
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ March 11, 2004: Message edited by: Dirk Schreckmann ]
 
brad balmer
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ March 11, 2004: Message edited by: Dirk Schreckmann ]
 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but when u r extending the 2nd class to the first wont it become an abstract class too. In that case i guess it doesnt answer the question right? jus curious...on how it works too.
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At a very simple level, an "abstract" class is simply one that can't be instantiated. However it can have variables and methods that are accessed just like any other variable/method.
If an "abstract" class has no "abstract" methods--as in the case of kan's "sample" class, then any subclass will be concrete, unless it is declared as "astract" as well. That's why Brad's example works.
If an "abstract" class has "abstract" methods, then for a subclass to be concrete [i.e., something you can instantiate] all of the "abstract" methods must be defined.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in fact, if you don't define all abstract methods in your subclass it won't even compile unless you declare the class as abstract.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!