Question
The Java API (Application Programming Interface) provides information about the libraries of tools and functionality that already exist in Java and that we can make
The Java API (Application Programming Interface) provides information about the libraries of tools and functionality that already exist in Java and that we can make use of in our programs. Each page of the API documents a specific class and lists its variables and methods. For now, well mostly be interested in these methods, since they tell us what operations are available, and how to correctly use them.
Each API page has two sections where it lists the methods of the class it focuses on. In the first list, it shows a quick description, which contains columns for the return type, method name and input parameters, and a summary of what it does, like this one for the method repeat:
Further down on the page, it lists each method again with much greater detail, like this:
Some classes have a large number of methods available, so scrolling through them to find a specific one can be inconvenient. While the page shows a search option at the top, this searches the entire Java API rather than the current page, and often wont give a helpful answer. Its generally better to use the standard find on page (usually Ctrl+F) and type in what youre looking for. When searching for a method, Ill usually follow the name with an opening parenthesis, like repeat(, since this will only match with the mentions at the start of these listings and not other uses of the word repeat on the page.
On the following pages, youll be directed to the Java API for the String, Math, and Random classes and be asked to find a few methods from them. Youll be asked to write the signature of those methods, with the output italicized and the input(s) underlined. Finally, you should give a quick description of the method in your own words. For the repeat method, I would write something like:
public String repeat(int count) creates a new String with the same contents as the current String, but repeated count times, for nonnegative counts.
1. For this first question, visit the Java API at the link below and find the information on the String class. Use this API to answer the following questions.
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html
The substring() method is listed twice, with different inputs for each. Write the signature of the first version listed in the space below; then, italicize the output type and underline the input(s) that the method requires. Write a quick description of what it does in your own words.
Type your answer to this question in this space.
Write the signature of the second version of substring() in the space below; then, italicize the output type and underline the input(s) that the method requires. Write a quick description that makes it clear how this version is different from the first substring() with fewer inputs.
Type your answer to this question in this space.
Find the information on the replace() method. Write the first signature from the list in the space below; then, italicize the output type and underline the input(s) that the method requires. Also include a brief description of the methods function in your own words.
Type your answer to this question in this space.
2. For this second question, visit the Java API at the link below and find the information on the Math class. Use this API to answer the following questions.
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html
Find the information on the floor() method. Write its signature in the space below; then, italicize the output type and underline the input(s) that the method requires. Also include a brief description of the methods function in your own words.
Type your answer to this question in this space.
Find the information on the log() method. Write its signature in the space below; then, italicize the output type and underline the input(s) that the method requires. Also include a brief description of the methods function in your own words.
Type your answer to this question in this space.
Find the information on the pow() method. Write its signature in the space below; then, italicize the output type and underline the input(s) that the method requires. Also include a brief description of the methods function in your own words.
Type your answer to this question in this space.
3. For this second question, visit the Java API at the link below and find the information on the Random class. Use this API to answer the following questions.
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Random.html
Find the information on the second version of the nextInt() method, the one with a bound. Write this signature from the list in the space below; then, italicize the output type and underline the input(s) that the method requires. Also include a brief description of the methods function in your own words.
Type your answer to this question in this space.
Find the information on the nextDouble() method. Write its signature in the space below; then, italicize the output type and underline the input(s) that the method requires. Also include a brief description of the methods function in your own words.
Type your answer to this question in this space.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started