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

    View Answer

    Workspace

    Discuss Discuss in Forum


  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.

    View Answer

    Workspace

    Discuss Discuss in Forum


  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

    View Answer

    Workspace

    Discuss Discuss in Forum


  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

    View Answer

    Workspace

    Discuss Discuss in Forum


  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.*

    View Answer

    Workspace

    Discuss Discuss in Forum


  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.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    View Answer

    Workspace

    Discuss Discuss in Forum


  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

    View Answer

    Workspace

    Discuss Discuss in Forum