wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inhertence of abstract () 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 "inhertence of abstract ()" Watch "inhertence of abstract ()" New topic

inhertence of abstract ()

Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131

Question is :-Given the following source code, which of the lines that are commented out may be reinserted without introducing errors?

one of the factors given in the explanation is:-

abstract void f( ) ; //(0)
"If this line is inserted, then class BigBang will have to be declared abstract. "

Is this a fact , that if a class extends a class with a abstract (),it must itself be declared abstract ?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
If you uncomment that line (//0) there is no implementation of the method in class Bang. So BigBang would have to implement it. But BigBang does not, so BigBang has to be declared abstract. But then we have a contradiction: BigBang is final and cannot be declared abstract! The final prevents BigBang being extended and method f from being provided with an implementation.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
Thx. Barry.
this was my cue [qoute] "So BigBang would have to implement it"
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
There are actually two issues with uncommenting this line. Do you see them both?

//BigBang(int n) { m = n } //(2)

Mike Gershman
SCJP 1.4, SCWCD in process
Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
Yes I do see that it'll no longer have a def. constructor that's used in the main().
Pavan Kumat

Joined: Dec 13, 2004
Posts: 10
Can uncomment following line without any problems -
//void k(){ i++; } //(3)

Can-not uncomment following line since ; is missing -
//BigBang(int n) { m = n } //(2)
I agree. Here's the link: http://aspose.com/file-tools
subject: inhertence of abstract ()
Similar Threads
One question from jQ+
Abstract Class?
a b c
null pointer exception