Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract class

 
Netty poestel
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm playing around with the abstract class.
one of the requirements on this topic is :-

"A class must be declared as abstract if it has one or more abstract methods or if it inherits abstract methods for which it does not provide an implementation."

hinting at the "....or if it inherits abstract methods for which it does not provide an implementation"

why can't I get the following code to compile, considering I am inheriting the abstract nethod?

--------------------------------

public abstract class hi{
abstract void foo(); }

public class hoi extends hi
{
public static void main(String xxx[])
{
}

public void foo(){}
}
-------------------------------

Thx.
 
tao wu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class hi is public and class hoi is public
Is this reason ?
[ September 29, 2004: Message edited by: Jonathan Schwartz ]
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correct, you can have only 1 public class per file.
 
Netty poestel
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gee...Thanks !
 
Netty poestel
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was confused, taking it as the interface which are always public abstract
...clear now..
Thx.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic