Java Packages Overview

Java Packages overview

2020-10

Select from among the following, classes which are stored in the java.sql package.

  1. Connection
  2. Writer
  3. Reader
  4. FileWriter
  5. ResultSet

Answer: (a) Connection and (e) ResultSet

The java.sql package is the foundation for Java Database Connectivity (JDBC) and contains classes and interfaces for interacting with databases.

  • (a) Connection is an interface in the java.sql package used to establish a connection with a database.
  • (e) ResultSet is an interface in the java.sql package used to hold data retrieved from a database after executing an SQL query.
  • (b) Writer, (c) Reader, and (d) FileWriter are part of the java.io package, which is used for input and output operations, specifically character streams for the first two and file writing for the last two. They are not related to database connectivity.

Java Packages — Quick Reference

A compact, beginner-friendly list of common Java packages with their meanings and utilities.

1. java.lang

Meaning

Core language classes automatically imported in every Java program.

Utilities

Fundamental classes such as String, Object, System, Math, and Thread. Used for basic language operations, exceptions, and threading.

2. java.util

Meaning

General-purpose utility classes and data structures.

Utilities

Collections like ArrayList, HashMap, HashSet, LinkedList; helpers like Random, Scanner, and Collections. Also older date/time types such as Date and Calendar.

3. java.io

Meaning

Blocking input/output (I/O) operations using streams and readers/writers.

Core Stream Classes:

  • InputStream and OutputStream: Abstract base classes for reading and writing byte streams, respectively.
  • Reader and Writer: Abstract base classes for reading and writing character streams, respectively.

Utilities

File and stream classes such as FileReader, BufferedReader, FileWriter, InputStream, and OutputStream. Commonly used for reading/writing files and binary/text streams.

4. java.nio & java.nio.file

Meaning

New I/O — modern, often more efficient I/O APIs (introduced in Java 1.4 and enhanced in Java 7).

Utilities

Buffers, channels, non-blocking I/O, and convenient file utilities such as Files and Paths. Preferred for high-performance or async I/O and filesystem operations.

5. java.net

Meaning

Networking and communication APIs.

Utilities

Classes like Socket, ServerSocket, URL, and URLConnection for TCP/UDP sockets and working with URLs.

6. java.awt

Meaning

Abstract Window Toolkit — basic desktop GUI and drawing primitives.

Utilities

Low-level GUI components, events, layout managers, and 2D drawing. Often used as the foundation for older GUI toolkits.

7. javax.swing

Meaning

Rich GUI toolkit built on top of AWT.

Utilities

Components such as JFrame, JButton, JPanel, and JTable. Used to build desktop applications with richer UIs than AWT alone.

8. java.applet (obsolete)

Meaning

API for applets that used to run inside web browsers (now deprecated/removed).

Utilities

Was used to create small browser-based Java programs; not used in modern Java development.

9. java.sql

Meaning

APIs for interacting with relational databases via JDBC.

Utilities

Core JDBC interfaces and classes such as Connection, Statement, PreparedStatement, and ResultSet for database CRUD operations.

10. javax.sql

Meaning

Extensions to JDBC for enterprise features.

Utilities

Connection pooling, DataSource, and other higher-level DB utilities used in production environments and application servers.

11. java.security

Meaning

Security, cryptography, and access-control APIs.

Utilities

Classes for encryption, keys, certificates, and secure random number generation. Useful for building secure applications and handling authentication/authorization tasks.

12. java.time

Meaning

Modern date & time API introduced in Java 8 (replacement for many java.util.Date use-cases).

Utilities

Types like LocalDate, LocalTime, LocalDateTime, Duration, and Period — with parsing/formatting and timezone support.

13. java.math

Meaning

High-precision numeric classes.

Utilities

BigInteger for arbitrarily large integers and BigDecimal for exact decimal arithmetic — ideal for financial and scientific calculations.

14. javafx.*

Meaning

Modern UI framework for desktop applications (graphics, media, and animation).

Utilities

Packages like javafx.application, javafx.scene, javafx.stage, and javafx.controls to build modern, animated interfaces.

15. java.util.concurrent

Meaning

Concurrency utilities for safer and simpler multithreading.

Utilities

Thread pools (ExecutorService), locks, atomic types, and concurrent collections to build scalable concurrent programs.

16. java.beans

Meaning

JavaBeans component architecture and introspection utilities.

Utilities

Support for property editors, bean introspection, and event handling for reusable components.

17. java.rmi

Meaning

Remote Method Invocation — remote object invocation across JVMs.

Utilities

APIs that allow calling methods on objects located on other machines; used to build distributed Java applications.

Popular posts from this blog

Evolution of computers and Computers today

Convert into binary

Processor Types and Specifications