Chapter 7: Java Standard and External Libraries

It is not possible to write a Java program without using the standard libraries, also called the Java Class Library (JCL). That is why a solid familiarity with such libraries is as vital for successful programming as knowing the language itself.

There are also the non-standard libraries, which are called external libraries or third-party libraries because they are not included in the Java Development Kit (JDK) distribution. Some of them have long become a permanent fixture of any programmer’s toolkit.

Keeping track of all the functionality that’s available in these libraries is not easy. This is because an integrated development environment (IDE) gives you a hint about the language’s possibilities, but it cannot advise you about the functionality of a package that hasn’t been imported yet. The only package that is imported automatically is java.lang.

The purpose of this chapter is to provide you with an overview of the functionality of the most popular packages of JCL, as well as external libraries.

In this chapter, we will cover the following topics:

  • Java Class Library (JCL)
  • External libraries

Technical requirements

To be able to execute the code examples in this chapter, you will need the following:

  • A computer with Microsoft Windows, Apple macOS, or the Linux operating system
  • Java SE version 17 or later
  • An IDE or code editor of your choice

The instructions on how to set up a Java SE and IntelliJ IDEA editor were provided in Chapter 1, Getting Started with Java 17. The files that contain the code examples for this chapter are available on GitHub in the https://github.com/PacktPublishing/Learn-Java-17-Programming.git repository, in the examples/src/main/java/com/packt/learnjava/ch07_libraries folder.

Java Class Library (JCL)

JCL is a collection of packages that implement the language. In simpler terms, it is a collection of the .class files that are included in the JDK and ready to be used. Once you have installed Java, you get them as part of the installation and can start building your application code up using the JCL classes as building blocks, which take care of a lot of the low-level plumbing. The richness and ease of use of JCL have substantially contributed to Java’s popularity.

To use a JCL package, you can import it without adding a new dependency to the pom.xml file. Maven adds JCL to the classpath automatically. And that is what separates the standard library and external libraries; if you need to add a library (typically, a .jar file) as a dependency in the Maven pom.xml configuration file, this library is an external one. Otherwise, it is a standard library or JCL.

Some JCL package names start with java. Traditionally, they are called core Java packages, while those that start with javax used to be called extensions. This was done because the extensions were thought to be optional and maybe even released independently of JDK. There was also an attempt to promote the former extension library to become a core package. But that would require changing the package name from java to javax, which would break the already existing applications that used the javax package. Therefore, the idea was abandoned, so the distinction between the core package and extensions gradually disappeared.

That is why, if you look at the official Java API on the Oracle website, you will see listed as standard not only the java and javax packages, but also jdk, com.sun, org.xml, and some other packages too. These extra packages are primarily used by the tools of other specialized applications. In this book, we will concentrate mostly on mainstream Java programming and talk only about the java and javax packages.

java.lang

This package is so fundamental that it doesn’t need to be imported for you to use it. The JVM authors decided to import it automatically. It contains the most often used classes of JCL:

  • Object: The base class of any other Java class.
  • Class: Carries metadata of every loaded class at runtime.
  • String, StringBuffer, and StringBuilder: Supports operations of the String type.
  • The wrapper classes of all primitive types: Byte, Boolean, Short, Character, Integer, Long, Float, and Double.
  • Number: The base class for the wrapper classes of the numeric primitive types – all the previously listed classes, except Boolean.
  • System: Provides access to important system operations and the standard input and output (we have used the System.out object in every code example in this book).
  • Runtime: Provides access to the execution environment.
  • The Thread and Runnable interfaces: Fundamental for creating Java threads.
  • The Iterable interface: Used by the iteration statements.
  • Math: Provides methods for basic numeric operations.
  • Throwable: The base class for all exceptions.
  • Error: This is an exception class since all its children are used to communicate system errors that can’t be caught by an application.
  • Exception: This class and its direct children represent checked exceptions.
  • RuntimeException: This class and its children represent unchecked exceptions, also called runtime exceptions.
  • ClassLoader: This class reads the .class files and puts (loads) them into memory; it also can be used to build a customized class loader.
  • Process and ProcessBuilder: These classes allow you to create other JVM processes.

Many other useful classes and interfaces are available as well.

java.util

Most of the content of the java.util package is dedicated to supporting Java collections:

  • The Collection interface: The base interface of many other interfaces of collections, it declares all the basic methods that are necessary to manage collection elements; for example, size(), add(), remove(), contains(), stream(), and others. It also extends the java.lang.Iterable interface and inherits its methods, including iterator() and forEach(), which means that any implementation of the Collection interface or any of its children – List, Set, Queue, Deque, and others – can be used in iteration statements too, such as ArrayList, LinkedList, HashSet, AbstractQueue, ArrayDeque, and others.
  • The Map interface and the classes that implement it: HashMap, TreeMap, and others.
  • The Collections class: This class provides many static methods that are used to analyze, manipulate, and convert collections.

Many other collection interfaces, classes, and related utilities are also available.

We talked about Java collections and saw examples of their usage in Chapter 6, Data Structures, Generics, and Popular Utilities.

The java.util package also includes several other useful classes:

  • Objects: Provides various object-related utility methods, some of which we looked at in Chapter 6, Data Structures, Generics, and Popular Utilities.
  • Arrays: Contains 160 static methods to manipulate arrays, some of which we looked at in Chapter 6, Data Structures, Generics, and Popular Utilities.
  • Formatter: This allows you to format any primitive type, including String, Date, and other types; we learned how to use it in Chapter 6, Data Structures, Generics, and Popular Utilities.
  • Optional, OptionalInt, OptionalLong, and OptionalDouble: These classes help avoid NullPointerException by wrapping the actual value that can be null or not.
  • Properties: Helps read and create key-value pairs that are used for application configuration and similar purposes.
  • Random: Complements the java.lang.Math.random() method by generating streams of pseudo-random numbers.
  • StringTokeneizer: Breaks the String object into tokens that are separated by the specified delimiter.
  • StringJoiner: Constructs a sequence of characters that are separated by the specified delimiter. Optionally, it is surrounded by the specified prefix and suffix.

Many other useful utility classes are available, including the classes that support internationalization and Base64-encoding and decoding.

java.time

The java.time package contains classes for managing dates, times, periods, and durations. The package includes the following:

  • The Month enum.
  • The DayOfWeek enum.
  • The Clock class, which returns the current instant, date, and time using a time zone.
  • The Duration and Period classes represent and compare amounts of time in different time units.
  • The LocalDate, LocalTime, and LocalDateTime classes represent dates and times without a time zone.
  • The ZonedDateTime class represents the date and time with a time zone.
  • The ZoneId class identifies a time zone such as America/Chicago.
  • The java.time.format.DateTimeFormatter class allows you to present the date and time as per the International Standards Organization (ISO) formats, such as the YYYY-MM-DD pattern.
  • Some other classes that support date and time manipulation.

We discussed most of these classes in Chapter 6, Data Structures, Generics, and Popular Utilities.

java.io and java.nio

The java.io and java.nio packages contain classes and interfaces that support reading and writing data using streams, serialization, and filesystems. The difference between these two packages is as follows:

  • The java.io package classes allow you to read/write data as it comes without caching it (as we discussed in Chapter 5, Strings, Input/Output, and Files), while classes of the java.nio package create buffers that allow you to move back and forth along the populated buffer.
  • The java.io package classes block the stream until all the data is read or written, while classes of the java.nio package are implemented in a non-blocking style (we will talk about the non-blocking style in Chapter 15, Reactive Programming).

java.sql and javax.sql

These two packages compose the Java Database Connectivity (JDBC) API, which allows you to access and process data that’s stored in a data source, typically a relational database. The javax.sql package complements the java.sql package by providing support for the following:

  • The DataSource interface as an alternative to the DriverManager class
  • Connections and statements pooling
  • Distributed transactions
  • Rowsets

We will talk about these packages and see code examples in Chapter 10, Managing Data in a Database.

java.net

The java.net package contains classes that support application networking at the following two levels:

  • Low-level networking, based on the following:
    • IP addresses
    • Sockets, which are basic bidirectional data communication mechanisms
    • Various network interfaces
  • High-level networking, based on the following:
    • Universal Resource Identifier (URI)
    • Universal Resource Locator (URL)
    • Connections to the resource being pointed to by URLs

We will talk about this package and see code examples of it in Chapter 12, Network Programming.

java.lang.math and java.math

The java.lang.math package contains methods for performing basic numeric operations, such as calculating the minimum and maximum of two numeric values, the absolute value, the elementary exponential, logarithms, square roots, trigonometric functions, and many other mathematical operations.

The java.math package complements Java primitive types and wrapper classes of the java.lang package as you can work with much bigger numbers using the BigDecimal and BigInteger classes.

java.awt, javax.swing, and javafx

The first Java library that supported building a graphical user interface (GUI) for desktop applications was the Abstract Window Toolkit (AWT) in the java.awt package. It provided an interface to the native system of the executing platform that allowed you to create and manage windows, layouts, and events. It also had the basic GUI widgets (such as text fields, buttons, and menus), provided access to the system tray, and allowed you to launch a web browser and email a client from the Java code. Its heavy dependence on the native code made the AWT-based GUI look different on different platforms.

In 1997, Sun Microsystems and Netscape Communications Corporation introduced Java Foundation Classes, later called Swing, and placed them in the javax.swing package. The GUI components that were built with Swing were able to emulate the look and feel of some native platforms but also allowed you to plug in a look and feel that did not depend on the platform it was running on. It expanded the list of widgets the GUI could have by adding tabbed panels, scroll panes, tables, and lists. Swing components are lightweight because they do not depend on the native code and are fully implemented in Java.

In 2007, Sun Microsystems announced the creation of JavaFX, which eventually became a software platform for creating and delivering desktop applications across many different devices. It was intended to replace Swing as the standard GUI library for Java SE. The JavaFX framework is located in the packages that start with javafx and supports all major desktop operating systems (OSs) and multiple mobile OSs, including Symbian OS, Windows Mobile, and some proprietary real-time OSs.

JavaFX has added support for smooth animation, web views, audio and video playback, and styles to the arsenal of a GUI developer, based on Cascading Style Sheets (CSS). However, Swing has more components and third-party libraries, so using JavaFX may require creating custom components and plumbing that was implemented in Swing a long time ago. That’s why, although JavaFX is recommended as the first choice for desktop GUI implementation, Swing will remain part of Java for the foreseeable future, according to the official response on the Oracle website (http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6). So, it is possible to continue using Swing, but, if possible, it’s better to switch to JavaFX.

We will talk about JavaFX and see code examples of it in Chapter 12, Java GUI Programming.

External libraries

Different lists of the most used third-party non-JCL libraries include between 20 and 100 libraries. In this section, we are going to discuss those libraries that are included in the majority of such lists. All of them are open source projects.

org.junit

The org.junit package is the root package of an open source testing framework’s JUnit. It can be added to the project as the following pom.xml dependency:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13.2</version>
    <scope>test</scope>
</dependency>

The scope value in the preceding dependency tag tells Maven to include the library .jar file, but only when the test code is going to be run, not in the production .jar file of the application. With the dependency in place, you can create a test. You can write the code yourself or let the IDE do it for you by doing the following:

  1. Right-click on the class name you would like to test.
  2. Select Go To.
  3. Select Test.
  4. Click Create New Test.
  5. Click the checkbox for the methods of the class you would like to test.
  6. Write code for the generated test methods with the @Test annotation.
  7. Add methods with the @Before and @After annotations if necessary.

Let’s assume we have the following class:

public class Class1 {
    public int multiplyByTwo(int i){
        return i * 2;
    }
}

If you follow the preceding steps, the following test class will be created under the test source tree:

import org.junit.Test;
public class Class1Test {
    @Test
    public void multiplyByTwo() {
    }
}

Now, you can implement the void multiplyByTwo() method, as follows:

@Test
public void multiplyByTwo() {
    Class1 class1 = new Class1();
    int result = class1.multiplyByTwo(2);
    Assert.assertEquals(4, result);
}

A unit is a minimal piece of code that can be tested, thus the name. The best testing practices consider a method as a minimal testable unit. That’s why a unit test usually tests a method.

org.mockito

One of the problems a unit test often faces is the need to test a method that uses a third-party library, a data source, or a method of another class. While testing, you want to control all the inputs so that you can predict the expected result of the tested code. That is where the technique of simulating or mocking the behavior of the objects the tested code interacts with comes in handy.

The open source Mockito framework (the org.mockito root package name) allows you to do just that – create mock objects. Using it is quite easy. Here is one simple case. Let’s assume we need to test another Class1 method:

public class Class1 {
    public int multiplyByTwo2(Class2 class2){
        return class2.getValue() * 2;
    }
}

To test this method, we need to make sure that the getValue() method returns a certain value, so we are going to mock this method. To do so, follow these steps:

  1. Add a dependency to the Maven pom.xml configuration file:

       <dependency>

           <groupId>org.mockito</groupId>

           <artifactId>mockito-core</artifactId>

           <version>4.2.0</version>

           <scope>test</scope>

       </dependency>

  2. Call the Mockito.mock() method for the class you need to simulate:

    Class2 class2Mock = Mockito.mock(Class2.class);

  3. Set the value you need to be returned from a method:

    Mockito.when(class2Mock.getValue()).thenReturn(5);

  4. Now, you can pass the mocked object as a parameter into the method you are testing that calls the mocked method:

    Class1 class1 = new Class1();

    int result = class1.multiplyByTwo2(class2Mock);

  5. The mocked method returns the result you have predefined:

    Assert.assertEquals(10, result);

  6. The @Test method should look as follows:

    @Test

    public void multiplyByTwo2() {

        Class2 class2Mock = Mockito.mock(Class2.class);

        Mockito.when(class2Mock.getValue()).thenReturn(5);

        Class1 class1 = new Class1();

        int result = class1.multiplyByTwo2(mo);

        Assert.assertEquals(10, result);

    }

Mockito has certain limitations. For example, you cannot mock static methods and private methods. Otherwise, it is a great way to isolate the code you are testing by reliably predicting the results of the used third-party classes.

org.apache.log4j and org.slf4j

Throughout this book, we have used System.out to display the results. In a real-life application, you can do this and redirect the output to a file, for example, for later analysis. Once you’ve been doing this a while, you will notice that you need more details about each output: the date and time of each statement, and the class name where the logging statement was generated, for example. As the code base grows, you will find that it would be nice to send output from different subsystems or packages to different files or turn off some messages, when everything works as expected, and turn them back on when an issue has been detected and more detailed information about code behavior is needed. And you don’t want the size of the log file to grow uncontrollably.

It is possible to write code that accomplishes all this. But several frameworks do this based on the settings in a configuration file, which you can change every time you need to change the logging behavior. The two most popular frameworks that are used for this are called log4j (pronounced as LOG-FOUR-JAY) and slf4j (pronounced as S-L-F-FOUR-JAY).

These two frameworks are not rivals. The slf4j framework is a facade that provides unified access to an underlying actual logging framework; one of them can be log4j too. Such a facade is especially helpful during library development when programmers do not know what kind of logging framework will be used by the application that uses the library in advance. By writing code using slf4j, the programmers allow you to configure it later so that you can use any logging system.

So, if your code is going to be used only by the application your team develops, using just log4j is enough. Otherwise, consider using slf4j.

As in the case of any third-party library, before you can use the log4j framework, you must add a corresponding dependency to the Maven pom.xml configuration file:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.17.0</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.17.0</version>
</dependency>

For example, here’s how the framework can be used:

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Class1 {
   static final Logger logger = 
               LogManager.getLogger(Class1.class.getName());
    public static void main(String... args){
        new Class1().multiplyByTwo2(null);
    }
    public int multiplyByTwo2(Class2 class2){
        if(class2 == null){
            logger.error("The parameter should not be null");
            System.exit(1);
        }
        return class2.getValue() * 2;
    }
}

If we run the preceding main() method, we will get the following output:

18:34:07.672 [main] ERROR Class1 - The parameter should not be null
Process finished with exit code 1

As you can see, if no log4j-specific configuration file is added to the project, log4j will provide a default configuration in the DefaultConfiguration class. The default configuration is as follows:

  • The log message will go to a console.
  • The pattern of the message is going to be %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n.
  • The level of logging will be Level.ERROR (other levels include OFF, FATAL, WARN, INFO, DEBUG, TRACE, and ALL).

The same result can be achieved by adding the log4j2.xml file to the resources folder (which Maven places on the classpath) with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] 
                              %-5level %logger{36} - %msg%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Root level="error">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>

If that is not good enough for you, it is possible to change the configuration so that it logs messages of different levels, to different files, and so on. Read the log4j documentation to learn more: https://logging.apache.org.

org.apache.commons

The org.apache.commons package is another popular library that’s been developed as a project called Apache Commons. It is maintained by an open source community of programmers called Apache Software Foundation. This organization was formed by the Apache Group in 1999. The Apache Group has grown around the development of the Apache HTTP Server since 1993. The Apache HTTP Server is an open source cross-platform web server that has remained the most popular web server since April 1996.

The Apache Commons project has the following three components:

  • Commons Sandbox: A workspace for Java component development; you can contribute to the open source work there.
  • Commons Dormant: A repository of components that are currently inactive; you can use the code there, but you must build the components yourself since these components will probably not be released soon.
  • Commons Proper: The reusable Java components that compose the actual org.apache.commons library.

We discussed the org.apache.commons.io package in Chapter 5, String, Input/Output, and Files.

In the following subsections, we will discuss three of Commons Proper’s most popular packages:

  • org.apache.commons.lang3
  • org.apache.commons.collections4
  • org.apache.commons.codec.binary

However, there are many more packages under org.apache.commons that contain thousands of classes that can easily be used to make your code more elegant and efficient.

lang and lang3

The org.apache.commons.lang3 package is version 3 of the org.apache.commons.lang package. The decision to create a new package was forced by the fact that changes that were introduced in version 3 were backward-incompatible, which means that the existing applications that use the previous version of the org.apache.commons.lang package may stop working after the upgrade to version 3. But in the majority of mainstream programming, adding 3 to an import statement (as a way to migrate to the new version) typically does not break anything.

According to the documentation, the org.apache.commons.lang3 package provides highly reusable static utility methods that are chiefly concerned with adding value to the java.lang classes. Here are a few notable examples:

  • The ArrayUtils class: Allows you to search and manipulate arrays; we discussed and demonstrated this in Chapter 6, Data Structures, Generics, and Popular Utilities.
  • The ClassUtils class: Provides some metadata about a class.
  • The ObjectUtils class: Checks an array of objects for null, compares objects, and calculates the median and minimum/maximum of an array of objects in a null-safe manner; we discussed and demonstrated this in Chapter 6, Data Structures, Generics, and Popular Utilities.
  • The SystemUtils class: Provides information about the execution environment.
  • The ThreadUtils class: Finds information about currently running threads.
  • The Validate class: Validates individual values and collections, compares them, checks for nulls and matches, and performs many other validations.
  • The RandomStringUtils class: Generates String objects from the characters of various character sets.
  • The StringUtils class: We discussed this class in Chapter 5, String, Input/Output, and Files.

collections4

Although the content of the org.apache.commons.collections4 package looks quite similar to the content of the org.apache.commons.collections package on the surface (which is version 3 of the package), the migration to version 4 may not be as smooth as just adding 4 to the import statement. Version 4 removed deprecated classes and added generics and other features that are incompatible with the previous versions.

You must be hard-pressed to come up with a collection type or a collection utility that is not present in this package or one of its sub-packages. The following is just a high-level list of features and utilities that are included:

  • The Bag interface for collections that have several copies of each object.
  • A dozen classes that implement the Bag interface. For example, here is how the HashBag class can be used:

      Bag<String> bag = new HashBag<>();

      bag.add("one", 4);

      System.out.println(bag);    //prints: [4:one]

      bag.remove("one", 1);

      System.out.println(bag);    //prints: [3:one]

      System.out.println(bag.getCount("one")); //prints: 3

  • The BagUtils class, which transforms Bag-based collections.
  • The BidiMap interface for bidirectional maps, which allow you to retrieve not only a value by its key but also a key by its value. It has several implementations, an example of which is as follows:

    BidiMap<Integer, String> bidi = new TreeBidiMap<>();

    bidi.put(2, "two");

    bidi.put(3, "three");

    System.out.println(bidi);  

                                   //prints: {2=two, 3=three}

    System.out.println(bidi.inverseBidiMap());

                                   //prints: {three=3, two=2}

    System.out.println(bidi.get(3));         //prints: three

    System.out.println(bidi.getKey("three")); //prints: 3

    bidi.removeValue("three");

    System.out.println(bidi);              //prints: {2=two}

  • The MapIterator interface to provide simple and quick iteration over maps, like so:

    IterableMap<Integer, String> map =

                 new HashedMap<>(Map.of(1, "one", 2, "two"));

    MapIterator it = map.mapIterator();

    while (it.hasNext()) {

          Object key = it.next();

          Object value = it.getValue();

          System.out.print(key + ", " + value + ", ");

                                    //prints: 2, two, 1, one,

          if(((Integer)key) == 2){

             it.setValue("three");

          }

    }

    System.out.println(" " + map);

                                   //prints: {2=three, 1=one}

  • Ordered maps and sets that keep the elements in a certain order, like List does; for example:

    OrderedMap<Integer, String> map = new LinkedMap<>();

    map.put(4, "four");

    map.put(7, "seven");

    map.put(12, "twelve");

    System.out.println(map.firstKey()); //prints: 4

    System.out.println(map.nextKey(2)); //prints: null

    System.out.println(map.nextKey(7)); //prints: 12

    System.out.println(map.nextKey(4)); //prints: 7

  • Reference maps, their keys, and/or values can be removed by the garbage collector.
  • Various implementations of the Comparator interface.
  • Various implementations of the Iterator interface.
  • Classes that convert arrays and enumerations into collections.
  • Utilities that allow you to test or create a union, intersection, or closure of collections.
  • The CollectionUtils, ListUtils, MapUtils, and MultiMapUtils classes, as well as many other interface-specific utility classes.

Read the package’s documentation (https://commons.apache.org/proper/commons-collections) for more details.

codec.binary

The org.apache.commons.codec.binary package provides support for Base64, Base32, binary, and hexadecimal string encoding and decoding. This encoding is necessary to make sure that the data you sent across different systems will not be changed on the way because of the restrictions on the range of characters in different protocols. Besides, some systems interpret the sent data as control characters (a modem, for example).

The following code snippet demonstrates the basic encoding and decoding capabilities of the Base64 class of this package:

String encodedStr = new String(Base64
                    .encodeBase64("Hello, World!".getBytes()));
System.out.println(encodedStr);  //prints: SGVsbG8sIFdvcmxkIQ==
System.out.println(Base64.isBase64(encodedStr)); //prints: true
String decodedStr = 
  new String(Base64.decodeBase64(encodedStr.getBytes()));
System.out.println(decodedStr);  //prints: Hello, World!

You can read more about this package on the Apache Commons project site at https://commons.apache.org/proper/commons-codec.

Summary

In this chapter, we provided an overview of the functionality of the most popular packages of JCL – that is, java.lang, java.util, java.time, java.io, java.nio, java.sql, javax.sql, java.net, java.lang.math, java.math, java.awt, javax.swing, and javafx.

The most popular external libraries were represented by the org.junit, org.mockito, org.apache.log4j, org.slf4j, and org.apache.commons packages. These help you avoid writing custom code in cases when such functionality already exists and can just be imported and used out of the box.

In the next chapter, we will talk about Java threads and demonstrate their usage. We will also explain the difference between parallel and concurrent processing. Then, we will show you how to create a thread and how to execute, monitor, and stop it. This will be useful not only for those who are going to write code for multi-threaded processing but also for those who would like to improve their understanding of how JVM works, which will be the topic of the following chapter.

Quiz

Answer the following questions to test your knowledge of this chapter:

  1. What is the Java Class Library? Select all that apply:
    1. A collection of compiled classes
    2. Packages that come with the Java installation
    3. A .jar file that Maven adds to the classpath automatically
    4. Any library that’s written in Java
  2. What is the Java external library? Select all that apply:
    1. A .jar file that is not included with the Java installation
    2. A .jar file that must be added as a dependency in pom.xml before it can be used
    3. Classes not written by the authors of JVM
    4. Classes that do not belong to JCL
  3. What functionality is included in the java.lang package? Select all that apply:
    1. It is the only package that contains Java language implementation.
    2. It contains the most often used classes of JCL.
    3. It contains the Object class, which is the base class for any Java class.
    4. It contains all the types listed in the Java Language Specification.
  4. What functionality is included in the java.util package? Select all that apply:
    1. All the implementations of Java collection interfaces
    2. All the interfaces of the Java collections framework
    3. All the utilities of JCL
    4. Classes, arrays, objects, and properties
  5. What functionality is included in the java.time package? Select all that apply:
    1. Classes that manage dates.
    2. It is the only package that manages time.
    3. Classes that represent date and time.
    4. It is the only package that manages dates.
  6. What functionality is included in the java.io package? Select all that apply:
    1. Processing streams of binary data
    2. Processing streams of characters
    3. Processing streams of bytes
    4. Processing streams of numbers
  7. What functionality is included in the java.sql package? Select all that apply:
    1. Supports database connection pooling
    2. Supports database statement execution
    3. Provides the capability to read/write data from/to a database
    4. Supports database transactions
  8. What functionality is included in the java.net package? Select all that apply:
    1. Supports .NET programming
    2. Supports sockets communication
    3. Supports URL-based communication
    4. Supports RMI-based communication
  9. What functionality is included in the java.math package? Select all that apply:
    1. Supports minimum and maximum calculations
    2. Supports big numbers
    3. Supports logarithms
    4. Supports square root calculations
  10. What functionality is included in the javafx package? Select all that apply:
    1. Supports fax-message sending
    2. Supports fax-message receiving
    3. Supports GUI programming
    4. Supports animation
  11. What functionality is included in the org.junit package? Select all that apply:
    1. Supports testing Java classes
    2. Supports Java units of measure
    3. Supports unit testing
    4. Supports organizational unity
  12. What functionality is included in the org.mockito package? Select all that apply:
    1. Supports the Mockito protocol
    2. Allows you to simulate a method’s behavior
    3. Supports static method simulation
    4. Generates objects that behave like third-party classes
  13. What functionality is included in the org.apache.log4j package? Select all that apply:
    1. Supports writing messages to a file
    2. Supports reading messages from a file
    3. Supports the log4j protocol for Java
    4. Supports controlling the number and size of log files
  14. What functionality is included in the org.apache.commons.lang3 package? Select all that apply:
    1. Supports Java language version 3
    2. Complements the java.lang classes
    3. Contains the ArrayUtils, ObjectUtils, and StringUtils classes
    4. Contains the SystemUtils class
  15. What functionality is included in the org.apache.commons.collections4 package? Select all that apply:
    1. Various implementations of Java collections framework interfaces
    2. Various utilities for Java collections framework implementations
    3. The Vault interface and its implementations
    4. Contains the CollectionUtils class
  16. What functionality is included in the org.apache.commons.codec.binary package? Select all that apply:
    1. Supports sending binary data across the network
    2. Allows you to encode and decode data
    3. Supports data encryption
    4. Contains the StringUtils class
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.108.236