aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock exam question doubt 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 "mock exam question doubt" Watch "mock exam question doubt" New topic
Author

mock exam question doubt

rajesh vasireddy
Greenhorn

Joined: Jun 06, 2009
Posts: 18
Replace two modifiers that appears in the Single class to make the code to compile.
Note: Three modifiers will not be used and four modifiers in the code will remain unchanged.
options given are...
final
protected
private
abstract
static
......................................................................
public class Single {
private static Single instance;
public static Single getInstance() {
if(instance==null)
instance=create();
return instance;
}
private Single(){}
protected Single create(){return new Single();}
}

class SingleSub extends Single{}
N.Senthil Kumar
Ranch Hand

Joined: Jul 07, 2009
Posts: 50


Hey Pal, You can replace the modifiers in the line 9 and 10 with protected and static respectively.

Make the constructor protected to make it visible to the SingleSub and you can replace protected to static in line 10 to make the code to compile, since in line 10 non-static create() is attempted to use in a static method getInstance(). either you can add static with protected in the line 10. but the ques is about replacing. Hence you can replace this two. to make you code to compile.

N.Senthil Kumar
rajesh vasireddy
Greenhorn

Joined: Jun 06, 2009
Posts: 18
thank you very much buddy...

Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3099
    
  40

And please QuoteYourSources


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
rajesh vasireddy
Greenhorn

Joined: Jun 06, 2009
Posts: 18
Hi Devaka Cooray,

Your Test Simulators are good.
Thank you for your valuable answer sir.

Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3099
    
  40

Is this from ExamLab?
 
 
subject: mock exam question doubt