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 super 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 super class." Watch "Abstract super class." New topic
Author

Abstract super class.

hanmeng
Greenhorn

Joined: Aug 16, 2000
Posts: 26
According the book: if super class is abstract, the subclass must be abstract or all methods must be abstract.
But I compiled following file. It's good, its subclass is not abstract, why it compiled with non-complain?
=====================================
abstract class Base{
abstract public void myfunc();
public void another(){
System.out.println("Another method");
}
}
public class Abs extends Base{
public static void main(String argv[]){
Abs a = new Abs();
a.amethod();
}
public void myfunc(){
System.out.println("My func");
}
public void amethod(){
myfunc();
}
}
1) The code will compile and run, printing out the words "My Func"
Sachin Kombrabail
Greenhorn

Joined: Aug 28, 2000
Posts: 14
Can you tell me which book told you that?
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Yeah, which book is that?
If a subclass doesnot implement all the abstract methods in the superclass, then -

  • The subclass itself should be declared as abstract
  • The superclass methods that are not implemented should be re-declared as abstract.

  • Hope this helps
    Ajith
    [This message has been edited by Ajith Kallambella (edited August 30, 2000).]


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
hanmeng
Greenhorn

Joined: Aug 16, 2000
Posts: 26
Thank you Ajith and Sachin
this words come from our class material book that not english words. I just translate it into Eglish
han
 
jQuery in Action, 2nd edition
 
subject: Abstract super class.
 
Similar Threads
if super class is abstract, subclass must be abstract?
abstract class
a question about two similar case ,one work while the other doesn't,why?
Abstarct class!
abstract