File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes all abstract methods must implemented by subclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "all abstract methods must implemented by subclass" Watch "all abstract methods must implemented by subclass" New topic
Author

all abstract methods must implemented by subclass

Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 402
In an ABSTRACT Class all abstract methods must implemented by subclass, well may not implemented and INSTEAD, implement overloaded methods of this abstract method?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

No, you have to implement the abstract method, with the same signature, in a subclass.
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

You have to implement all the abstract methods, unless if your sub class is also a abstract class!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

please try it yourself that is a best way to learn.
You will surely get a compiler error if you donot implement the abstract methods unless and untill your subclass is also a abstract class.


SCJP6.0,My blog Ranchers from Delhi
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 402
this applies and to Stream chain of classes?
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Leonidas Savvides wrote:this applies and to Stream chain of classes?

What happen when you try it?


http://muhammadkhojaye.blogspot.com/
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 402
See the BOLD Text of my book, below...

4.4.1 Writers
The Writer class mirrors the java.io.OutputStream class. It's abstract and has two protected constructors. Like OutputStream, the Writer class is never used directly; instead, it is used polymorphically, through one of its subclasses. It has five write() methods as well as a flush( ) and a close( ) method:

protected Writer( )

protected Writer(Object lock)

public abstract void write(char[] text, int offset, int length)

throws IOException

public void write(int c) throws IOException

public void write(char[] text) throws IOException

public void write(String s) throws IOException

public void write(String s, int offset, int length) throws IOException

public abstract void flush( ) throws IOException

public abstract void close( ) throws IOException


The write(char[] text, int offset, int length) method is the base method in terms of which the other four write( ) methods are implemented. A subclass must override at least this method as well as flush( ) and close(), although most override some of the other write( ) methods as well in order to provide more efficient implementations. For example, given a Writer object w, you can write the string "Network" like this:

char[] network = {'N', 'e', 't', 'w', 'o', 'r', 'k'};

w.write(network, 0, network.length);


The same task can be accomplished with these other methods, as well:

w.write(network);

for (int i = 0; i < network.length; i++) w.write(network[i]);

w.write("Network");

w.write("Network", 0, 7);
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

Leonadis, I expected that you know how to UseCodeTags by now...


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Leonidas Savvides wrote:See the BOLD Text of my book, . . .
Which book?
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 402
Java Network Programming, 3rd Edition OREILLY
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: all abstract methods must implemented by subclass
 
Similar Threads
Page 129 - K&B 1.4 - Abstract Methods
Abstract class method
English: it's so easy to mean something you didn't mean to mean
abstract classes
Why can't declare a Static method in Interface?