Home / CSE MCQs / JAVA MCQs :: Packages

CSE MCQs :: JAVA MCQs

  1. Which of these keywords is used to define packages in Java?
  2. A.
    pkg
    B.
    Pkg
    C.
    package
    D.
    Package

  3. Which of these is a mechanism for naming and visibility control of a class and its content?
  4. A.
    Object
    B.
    Packages
    C.
    Interfaces
    D.
    None of the Mentioned.

  5. 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?
  6. A.
    Public
    B.
    Protected
    C.
    No Modifier
    D.
    All of the mentioned

  7. Which of these access specifiers can be used for a class so that it's members can be accessed by a different class in the different package?
  8. A.
    Public
    B.
    Protected
    C.
    Private
    D.
    No Modifier

  9. Which of the following is correct way of importing an entire package 'pkg'?
  10. A.
    import pkg.
    B.
    Import pkg.
    C.
    import pkg.*
    D.
    Import pkg.*

  11. Which of the following is incorrect statement about packages?
  12. A.
    Package defines a namespace in which classes are stored.
    B.
    A package can contain other package within it.
    C.
    Java uses file system directories to store packages.
    D.
    A package can be renamed without renaming the directory in which the classes are stored.

  13. Which of the following package stores all the standard java classes?
  14. A.
    lang
    B.
    java
    C.
    util
    D.
    java.packages

  15. What is the output of this program?
    package pkg;
    class output {
    public static void main(String args[])
    StringBuffer s1 = new StringBuffer("Hello");
    s1.setCharAt(1, x);
    System.out.println(s1);
    }
    }
  16. A.
    xello
    B.
    xxxxx
    C.
    Hxllo
    D.
    Hexlo