MCQs
Total Questions : 10
Answer: Option D. -> Runtime error
Since output.class file is not in the directory pkg in which class output is defined, program will
not be able to run.
output:
$ javac output.java
$ java output
can not find file output.class
Answer: Option C. -> Hxllo
None.
Output:
$ javac output.java
$ java output
Hxllo
Answer: Option C. -> 2
None.
Output:
$ javac packages.java
$ java packages
2
Answer: Option B. -> java
None.
Answer: Option D. -> A package can be renamed without renaming the directory in which the classes are stored.
A package can be renamed only after renaming the directory in which the classes are stored.
Answer: Option C. -> import pkg.*
Operator * is used to import the entire package.
Answer: Option A. -> Public
None.
Answer: Option D. -> All of the mentioned
Either we can use public, protected or we can name the class without any specifier.
Answer: Option C. -> package
None.
Answer: Option B. -> Packages
Packages are both naming and visibility control mechanism. We can define a class inside a
package which is not accessible by code outside the package.