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

keyword called default?

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is There any Keyword called "default". public,private,protected and default
are called access specifiers. I typed in the following code and got a compiler error. I just want to know whether the default access specifier is implicit or can we use it explicitly? Please clarify on this.
Thanks

[ January 08, 2008: Message edited by: Thirumalai Muthu ]
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi thirumalai,

Yes default is a key word and you cannot use it as a variable name or as identifier. For further clarity refer K&B book and check in the table listed out.

when you dont specifically mention any access level modifiers then its understood as it has default level access.

ex:
int a; // has default level access
public int a; //has got public access.


i think this helps, before asking any question just refer K&B book, at later stage api , experiment with your own code and then post question.
 
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
Yes, there is a keyword called "default" but it does not have anything to do with access specifiers (public / protected / private). "default" can be used in a switch block:
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Talking about keywords, from the top of my head: There is a even cuter keyword: const!

It is not used in anyway, but probably reserved in the creation of Java, and then they never done anything with it. const is a very often used keyword in C++ though, and there it tells the conpiler that a variable is immutable, and the compiler gives you an error when you act against it.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thirumalai:

Take the Jesper's answer, default is a keyword for a switch statement, when no one of the cases are matched, then the default works. In access modifier default access doesn't have keyword, you just don't write an access modifier and you have it, i.e. int a; has default access.
 
Thirumalai Muthu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys. Thank you very much for your replies. The reason Why I asked you this question was I was asked the same question in an Interview, But now I understood.Thank you very much
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No matter what, the line



is a good try and it made you learn! Happy about it
 
Thirumalai Muthu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Raghavan I learnt it and i wont forget it ever in my life

And raghavan you have been really helpful in answering the Ranchers queries and I think you deserve a title more than that of a Ranch hand.
[ January 08, 2008: Message edited by: Thirumalai Muthu ]
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's great Thirumalai Muthu.

My Pleasure
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic