Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Modifiers

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Replace two of the Modifiers that appear in the Single class to make the code compile. NOTE: Three Modifiers will not be used and four modifiers will remain unchanged.

code:

public class Single{

private static single instance; // Change the Modifier (private,static)

public static Single getInstance(){ // Change the Modifier(public,static)

if(instance == null) instance = create();

return instance;

}

private Single(){} //Change the Modifier

protected Single create() { return new Single(); } //Change the Modifier

}

class SingleSub extends Single{ }


Modifiers :

1. final
2. protected
3. private
4. abstract
5. static
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suresh, when you copy a question from a book or mock exam, we require that you quote your sources. So, please tell us where you copied it from.

As with your previous question: Just try it out for yourself to see what compiles and what doesn't.
[ August 18, 2008: Message edited by: Jesper Young ]
 
Sheriff
Posts: 9692
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the create method will have to be made static as static getInstance method access it directly...

the constructor will have to be made protected as the SingleSub class inherits from it and the constructor is private...
 
Water proof donuts! Eat them while reading this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic