default package?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Q4 which of the following is the correct way to define a class that will be in the default package
A1
package default;
import java.util.*;
A2 import java.util.*;
package default;
A3 import java.util.*;
A4
all the above
The answer explanation is given like:
[Even if you don't write "package default" your class will automatically
placed in the "default" package.] What is this "default" package?
I see this irrelevant. "default" is the keyword so, it will yield compilation error.
Please any comment!
Regards,
cmbhatt
[ April 09, 2007: Message edited by: Chandra Bhatt ]
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
regards,
Sharan...
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I think correct option is A3. please compile it i think you will definetly get the answer
Best of luck.

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
When you don't define a package statement in your class then the default-package will be created.
Also the package statement should be the first statement in your code after declaring the class name.
Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The 'default' keyword applies only in the case of a switch-case construct.
When talking about default packages (and access specifier), default means the 'absence' of any keyword or identifier. So, in common parlance, when you say default package, it means unnamed package. There is no question of using the string 'default' to name it.
cheers.
ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted By Remko:
When you don't define a package statement in your class then the default-package will be created.
I dont find any default-package. As you say if you don't define package,
default package will be created. Is your answer influenced by the stated
behavior of different Java IDE's which creates default-package in case not
package statement in your class?
package means what to you? a directory will be created?
-cmbhatt
[ April 09, 2007: Message edited by: Chandra Bhatt ]
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
but a in "default" package.
I do'nt think so.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Stuart Ash has explained everything clear for you.
He has done a good job.
Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
By the way, you can not use package name "default", as "default" is a java reserved keyword.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Ans A3 is correct for Default package
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Remko Strating:
With the default package I mean there is no package defined. So the compiled class file will be in the same directory.
Stuart Ash has explained everything clear for you.
He has done a good job.
Thank you Remko
and Patrick for seconding

ASCII silly question, Get a silly ANSI.
| I don't like that guy. The tiny ad agrees with me. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








