11.) When might you encounter a naming collision while importing classes?
A) When using wildcard imports
B) When importing classes from the same package
C) When importing classes from different packages
D) When using fully qualified class names
12.) What is the advantage of using named packages over the default package?
A) Default packages have better access to built-in classes.
B) Named packages prevent naming conflicts.
C) Default packages offer faster runtime performance.
D) Named packages automatically import all classes.
13.) Can a class belong to multiple packages simultaneously?
A) Yes, but it requires advanced import statements.
B) No, a class can belong to only one package.
C) Yes, but it causes naming conflicts.
D) Yes, if it’s placed in the default package.
14.) Which statement is true about packages and directories in Java?
A) Each package corresponds to a separate directory.
B) Packages are not related to directory structure.
C) Directories are created automatically for each class.
D) Packages and directories have opposite structures.
15.) What’s the purpose of the CLASSPATH environment variable?
A) It sets the default package for a project.
B) It defines the location of Java compiler.
C) It specifies where to find compiled classes and packages.
D) It is used for creating class documentation.
16.) Which of the following is NOT a benefit of using packages in Java?
A) Organizing and managing code
B) Reducing naming conflicts
C) Improving runtime performance
D) Enhancing code readability
17.) If you have classes A and B in package myPackage, which import statement is correct to use them in another class?
A) import myPackage.*;
B) import myPackage.A, B;
C) import A, B from myPackage;
D) import class myPackage.A, myPackage.B;
18.) What happens if you attempt to use a class without an import statement or fully qualified name?
A) The program compiles but throws a runtime error.
B) The program compiles and uses the class from the default package.
C) The program doesn’t compile due to an import error.
D) The program doesn’t compile due to a missing package declaration.
19.) Can two classes with the same name exist in different packages?
A) No, class names must be unique across all packages.
B) Yes, but they must have distinct method names.
C) Yes, but it leads to naming conflicts.
D) No, Java enforces unique class names globally.
20.) What is the role of a manifest file in Java packages?
A) It defines the directory structure of packages.
B) It contains metadata about the package and its classes.
C) It specifies import statements for package classes.
D) It is used to set the CLASSPATH environment variable.