• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a question about modifier

 
dragon ji
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question is from the book <Complete Java 2 Certification Study Guide>.
question:
Whick one of the following statement is true?
A. An abstract class may not have any final methods.
B. A final class may not have any abstract methods.
answer:
B. Any class with abstract methods must itself be abstract,and a class may not be both abstract and final.Statement A says that an abstract class may not have final methods,but there is nothing wrong with this.The abstract class will eventually be subclassed,and the subclass must avoid overriding the parent's final methods.Any other methods can be freely overridden.
But I think the answer A is correct,too.
Anybody can help me,please?
 
Alfred Kemety
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An abstract class does not dictate that all its methods be abstract. An abstract method essentialy dictate that 1- it can't be instanciated, 2- Subclasses that are not abstract should implement the abstract methods in the super abstract class.
You can have implemented methods or even final methods in an abstract class...
I have to run now, my exam in is 2 hours wish me good luck
 
dragon ji
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but A says "may not",it doesn't say "must not"or "can't",so I think A is right.but.....
why?please......
 
Arpana Rai
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In option A "any final methods" can be taken as both abstract and non-abstatct method,but only non-abstract method can have final modiefier.that is y option A is not correct even though it contains the condition "may".Hope i am clear.
regds
Arpana
 
dragon ji
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,Arpana
I'm sorry I don't think so.
I think the author regard the "may not" as "can't",so option A is wrong.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic