Java Interview Questions - java.util package

1. Define package?

package is a collection of group of similar types of classes , interfaces and sub packages.

2. State the use of package?

  1. package use to search .class file very faster.
  2. It is use to categorise classes & interfaces so that they can be easily maintained.
  3. package use to remove naming collision.

3. Describe types of package & Describe them?

package categorized into 2 types:

  1. Built-in package - Built-in package-If the package already design & stored in the predefined class then it is known as Built –in package.
  2. user-definedpackage - User-defined package-User-defined classes are the collection of user definedclasses.

4. What are the advantages of package?

  1. package provides access protection.
  2. package removes naming collision.

5. How to access package from another package?

There are 3 ways to access the package from another package:

  1. import package.*;
  2. importpackage.classname.
  3. fullyqualifiedname.

6. State the use of import keyword?

The import keyword used to make the classes and interfaces of another package accessible to the current package.

7. How much pre-defined package java supports?

80,000 classes present in 202 no of packages.

8. Who is the default package in java?

Lang is the default package in java.

9. State the use of package keyword?

The package keyword is used to create a package.

10. When to use fully qualified name?

We need to use fully qualified name every time when accessing the classes and interfaces.

11. State the operation & package of Socket& ServerSocket classes?

Socket & Server socket class present in net package and its operation mainly for networking purpose.

12. Input/Output classes present in which package?

Input/Output classes present in io package.

13. What are the ways to load class file?

There are 2 ways to load class file:

  1. Temporary
  • by setting the class path in the command prompt.
  • by class path switch.
  1. Permanent
  • by setting the class path in the environment variable. b) by creating the jar file.

14. How to create document API in java?

Document API can create in java by the help of javadoc tool.

15. State the condition where fully qualified name in compulsory?

Fully qualified name is compulsory when accessing the classes and interfaces.

16. How to execute .class file?

JVM execute the .class file.

17. Which package is used for achieving the language Functionalities?

java.lang.* is used for language functionalities.

18. Which package is used for developing file handling application?

java.io.* is used for file handling application.

19. Which package is used for developing GUI components?

java.awt.* is used for GUI components.

20. Which package is used for developing browser oriented application?

java.applet.* is used for browser oriented application.

21. Which package is used for developing client server application?

java.net.* is used for client server application.

22. Which package is used for developing quality or reliable application in java?

java.util.* is used for quality or reliable application in java.

23. Which package is used for formatting data and time on day to day business operation?

java.text.* is used for formatting data and time on day to day business operation.

24. State the use of Event package?

This package is used for providing the functionality of GUI components.

25. Which package is also known as collection framework in java?

java.util.* is also known as collection framework in java.

26. Which package is used for runtime information about the class and interface?

java.lang.reflect.* is used for study run time information about the class and interface.

27. Which package is used for retrieving data from database & performing various operation on database?

java.sql.* is used for retrieving data from db & performing various operation on db.