This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Abstract class" Watch "Abstract class" New topic
Author

Abstract class

Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
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

Joined: Sep 18, 2004
Posts: 8
class hi is public and class hoi is public
Is this reason ?
[ September 29, 2004: Message edited by: Jonathan Schwartz ]

Boy From PRC<br />SCJP1.4
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
correct, you can have only 1 public class per file.


42
Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
Gee...Thanks !
Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
I was confused, taking it as the interface which are always public abstract
...clear now..
Thx.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract class
 
Similar Threads
Abstract Class and methods
Abstract definition & Interface
Help With Classes Needed
Difference between Interface and Abstract class
Regarding Abstraction