Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which statements are true?

 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) An abstract class is allowed to have non-abstract methods.
2) If a class has abstract methods, it must be declared abstract.
3) A non-abstract class is allowed to have abstract methods.
4) A non-abstract class is allowed to have abstract methods as long as those methods are also static.
My book says 1 & 2 are correct.
1 is obviously true and 4 is definately false. However, I felt that 2 was false because if a class extends a abstract class and overrides all abstract methods....it doesn't have to be abstract. And I felt that 3 was true for the same reason.
Correct me if I am wrong.
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your books says true!

if a class extends a abstract class and overrides all abstract methods...

Then there is no abstract method in the subclass!.Since it gives implementation to abstarct methods in its super class by overriding.
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. I see that now. I'll write a few of these scenarios to let it sink in.
Thanks.
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a class has an abstract method, the class must be declared abstract so 3 is false.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
Co-author Mike Meyers' Java 2 Certification Passport
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic