Q4 which of the following is the correct way to define a class that will be in the default package A1
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.
I think there is a confusion here: about default the concept and default the keyword.
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.
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 JavaIDE's which creates default-package in case not package statement in your class?
package means what to you? a directory will be created?