InstructionsTotal Questions: 25Total Minutes: 25This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on the basics of Java Package Rules. This practice test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics. Go through Java Theory Notes on Packages Rules before attempting this test. All the Best Challenge SCORE0 / 25Take This Exam 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20*21*22*23*24*25*Q Buttons 1) What is a package in Java? A) A Package is a collection of files of type Java Class, Interfaces, or Abstract Class B) A Package is simply a Directory or Folder with Java Classes C) A Package usually contains Java Classes written for a specific purpose or problem D) All the above 2) Choose the correct syntax of a Java Package below. A) package PACKAGE_NAME; B) package PACKAGE_NAME.*; C) pkg PACKAGE_NAME; D) pkg PACKAGE_NAME.*; 3) The keyword used to declare a Java package is ____. A) pkg B) package C) pkge D) None of the above 4) What is the maximum number of Java Class files that can be kept inside a single Java Package? A) 8 B) 64 C) 128 D) Unlimited 5) Can you compile a Java file kept inside a directory without mentioning the package name? folder_1 ----- SomeFile.java . . //SomeFile.java //no package declaration //package folder_1; commented public class SomeFile { } A) Yes B) No C) - D) - 6) The name of a package is the name of the ___ in Java. A) folder B) All parent folders separated by DOT symbols C) All parent packages separated by DOT symbols D) All the above 7) It is possible to declare a package and import another package within the same Java class file. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - Ad 8) The keyword used to import a package into Java class or Interface is ___. A) import B) download C) use D) None of the above 9) Which is the correct syntax to import a Java package below? A) import PACKAGE1.*; B) import PACKAGE1.CLASS1; C) import PACKAGE1.PACKAGE2.PACKAGE3.*; D) All the above 10) Choose correct declaration and importing of packages in Java. A) package SOMEPACKAGE; import PACKAGE_N.*; B) import PACKAGE_N.*; package SOMEPACKAGE; C) import PACKAGE_M.*; package SOMEPACKAGE; import PACKAGE_N.*; D) All the above 11) You can use the same name for a Parent package and Child package in Java. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 12) What is the maximum number of levels or depth up to which sub-packages can be defined in Java? A) 8 B) 16 C) 32 D) There is no limit 13) Choose a correct statement below about importing packages into a class. A) A Java class or interface can import any number of packages. B) It is advised to import only the required Classes of a package to save memory. C) Java packages are usually distributed in the form of JAR files. D) All the above 14) When importing a Package, the Class is actually importing ____. A) Classes or Interfaces from the package B) Constants C) Methods D) None of the above Ad 15) The package declaration statement should be the first statement in a Java file. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 16) You can place a comment before the Package Declaration statement in Java. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 17) How does JAVAC or JAVA (JVM) find the packages that will be used inside classes by an import statement? A) If the packages are defined on the same root level as the compiling or running class file, Java knows it. B) You should manually use the CLASSPATH or CP command to include the path of the package or single-class for compiling and running C) You can copy the JAR files in LIB folder of Java inside Program Files D) All the above 18) Which is the default Java package that will be auto included (imported) in the classpath while Compiling and Running a Java program? A) java.io B) java.util C) java.net D) java.lang 19) What are the popular Classes or Interfaces inside a Java Language Pack (java.lang)? A) Byte, Character, Short, Integer, Float, Long, Number B) Math, String, StringBuffer, StringBuilder C) Thread, Throwable, Exception, Error D) All the above 20) Choose a correct way of importing all the classes in the below java program with packages. //Cat.java package animals; public class Cat { } //Dog.java package animals; public class Dog { } //PackageTesting.java //import statements public class { //new Cat(); //new Dog(); } A) import animals.*; B) import animals.cat; import animals.Dog; C) Both A and B D) None 21) Which is the symbol used to separate a super-package and a sub-package at the time of declaring or importing in a Java program? A) Dollar ($) B) Pound (#) C) Period (.) or DOT D) Arrow (->) Ad 22) Choose a correct statement about using the classes or interfaces or abstract classes inside the packages in our Java program. A) You can extend the class imported from the package. B) You can implement the interfaces imported from the package. C) You can extend the abstract classes imported from the package. D) All the above 23) Accessing the variables, constants, or methods of a class, imported from a package is subjective to access modifiers like PUBLIC, PRIVATE, PROTECTED and default. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - 24) What are the uses of a Java Package? A) A package contains ready-to-use classes written for a specific purpose. B) Packages are easy to distribute your code. It is nothing but reusability. Instead of writing code afresh, you can take advantage of the existing classes of a package. Simply import it and use. C) Packages help in maintaining the code easily. Each sub-package may be maintained for more specific purposes. You can reuse the class names in sub-packages or other packages without name clash. D) All the above 25) What is the output of the below Java program with packages? //MathClas.java package package1; public class MathClass { public static int getRandom() { //returns a random number from 0 to 999 return ((int) (Math.random() * 1000)); } } //PackageTest3.java import package1.*; public class PackageTest3 { public static void main(String[] args) { System.out.print(MathClass.getRandom()); } } A) No output B) Compiler error C) 484 (some random number) D) None FINISH EXAM 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20*21*22*23*24*25*PREV Java Interface Online Test NEXT Java Access Modifiers Online Test