Java Packages MCQ Questions

This section focuses on "packages" in Java programming language. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.

1. Package in Java is a mechanism to encapsulate a ______________.

A. Classes
B. Sub Packages
C. Interfaces
D. All of the above

View Answer


2. Which of these keywords is used to define packages in Java?

A. pkg
B. Pkg
C. package
D. Package

View Answer


3. Package names and directory structure are closely related.

A. TRUE
B. FALSE
C. can be true or false
D. can not say

View Answer


4. An _______________ statement can be used to access the classes and interface of a different package from the current package.

A. instanceOf
B. import
C. extends
D. implement

View Answer


5. Which of the following packages is used to includes classes to create user interface like Button and Checkbox?

A. java.lang
B. java.net
C. java.awt
D. java.io

View Answer


6. Which of the following packages is used to includes utility classes like Calendar, Collection, Date?

A. java.lang
B. java.net
C. java.awt
D. java.util

View Answer


7. Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?

A. Public
B. Protected
C. No Modifier
D. All of the mentioned

View Answer


8. Which of the following is the correct way of importing an entire package "pkg"?

A. import pkg.
B. Import pkg.
C. import pkg.*
D. Import pkg.*

View Answer


9. Which of the following is false statement about package in java?

A. Packages are used for preventing naming conflicts
B. Providing controlled access: protected and default have package level access control.
C. Packages cannot be considered as data encapsulation
D. Both B and C

View Answer


10. Packages that are inside another package are the _________

A. packages
B. nested packages
C. util subpackages
D. subpackages

View Answer




Discussion



* You must be logged in to add comment.