File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes An abstract class can not extend a concrete class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "An abstract class can not extend a concrete class?" Watch "An abstract class can not extend a concrete class?" New topic
Author

An abstract class can not extend a concrete class?

Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Hello,
In one of Dan's exams i came across the following statement:
An abstract class can not extend a concrete class.
I thought this statement was true, but according to Dan it is wrong, so i wrote the following code

The code compiles fine without error, which means my answer is correct. Did Dan made a mistake with this question? (Which is highly unlikely) or i simply misunderstood the meaning of concrete class?
I don't see the point why an abstract class should not extend another class!!!
Any help will be appreciated.


- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Hi Vicken,
It is true that an abstract class can extend a concrete class.
So I went in search of where Dan might have said otherwise. Here is Dan�s Single Topic Exams, Chapter 4, Exam 1, Question 15. See option f.
Which of the follow statements is true.
a. An anonymous class can be declared abstract.
b. A local class can be declared abstract.
c. An abstract class can be instantiated.
d. An abstract class is implicitly final.
e. An abstract class must declare at least one abstract method.
f. An abstract class can not extend a concrete class.
Here is Dan�s Answer:
15 b A local class can be declared abstract.
An anonymous class can not be extended; therefore, an anonymous class can not be declared abstract. A local class can be abstract. An abstract class can not be instantiated. If a class declaration contains an abstract method, then the class must also be declared abstract. A class can be declared abstract even if it does not contain an abstract method. An abstract class can never be declared final.
Therefore, in this question and answer Dan is saying f is false.
Dan's Single Topic Exams, Chapter 4, Exam 1
Dan's Single Topic Exams, Chapter 4, Exam 1, Answers
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Hi MM,
The qestion i posted was from Dan's Study Guide (April 18), Exam-2, Question 14

Which of the follow are true statements.
a. An anonymous class can be declared abstract.
b. An incompletely implemented class must be declared abstract.
c. A local class can be declared abstract.
d. An abstract class can be instantiated.
e. An abstact class is implicitly final.
f. An abstact class must declare at least one abstract method.
g. An abstact class can not extend a concrete class.
h. None of the above.

Dan's Answers are: b,c
An anonymous can not be extended therefore an anonymous class can not be declared abstract. Even a local class can be abstract. An abstract class can not be instantiated. Any class that declares an abstract method must also be abstract. A class can be declared abstract even if it does not declare an abstract method. An abstract class can never be declared final.

I checked Dan's site and it seems that the question does not exist anymore. He may have corrected the answer in his latest update (Dec 20).
Thanks MM.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Hi Vicken,
In the example you cite, the answer says b and c are true statements, hence g is false. Since g is false, the answer is saying an abstract class can extend a concrete class.
g. An abstact class can not extend a concrete class.
I think the problem here is just sorting out which statements are true and which are false.
[ December 26, 2003: Message edited by: Marlene Miller ]
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Yes, you are right MM, it seems that i missed the not in that statement .After all Dan was right and i was wrong. I should take a little brake, cause sitting hours and hours in front of the PC is definitely not helping.
So simply put, the statement: An abstract class can not extend a concrete class. is FALSE.
[ December 26, 2003: Message edited by: Vicken Karaoghlanian ]
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Ah. I think you have discovered the root of the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An abstract class can not extend a concrete class?