aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Abstract Methods" Watch "Abstract Methods" New topic
Author

Abstract Methods

Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
I have never really had to use Abstract methods in my coding. I am however, trying to get a jump on the SCJP exam. So, my question is this: What is the fundamental difference between Abstract methods and NON-Abstract methods?
Thanks,


Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Pradeepa Battina
Greenhorn

Joined: Jan 08, 2002
Posts: 3
The fundamental difference is that an abstract method has no code and a non abstract method or
a concrete method is one which has code in it.
And the class with an abstract method should be
declared abstract.Any class which extends the abstract class should have methods which override
the abstract methods in its super class or it should be declared abstract.
mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
you declare an abstract method, so that the implementers or other designers who use this class have to write their code ie concrete code for such methods. ie the functionality in the method is left to the person who would be sub-classing that class. How he does is his business, but he has to... if he wants to subclass that class. if he does not then better declare your class as abstract as well.

Originally posted by Jason Kretzer:
I have never really had to use Abstract methods in my coding. I am however, trying to get a jump on the SCJP exam. So, my question is this: What is the fundamental difference between Abstract methods and NON-Abstract methods?
Thanks,
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
So when a class that is declared Abstract is subclassed, none of the Abstract methods in the superclass HAVE to be implemented? But if the class were not Abstract then the subclass do HAVE to be implemented.
Is this correct?
mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
i don't think you got it.
abstract class A {
void method one();==> note semicolon
void method ok()
{//some-code here}
}
class B extends A {
void method one()===> no semicolon because....
{//put code here}
}
if you don't implement method one in class B then declare class B as abstract.
I hope now its clear
Originally posted by Jason Kretzer:
So when a class that is declared Abstract is subclassed, none of the Abstract methods in the superclass HAVE to be implemented? But if the class were not Abstract then the subclass do HAVE to be implemented.
Is this correct?
 
Consider Paul's rocket mass heater.
 
subject: Abstract Methods
 
Similar Threads
Which statements are true?
Abstract Class
a question about modifier
HF-pg98 : HttpServlet is an abstract class ?
abstract class