Question: Java Answer these questions by looking things up in the Java API. Use the following format when making work: copy the task and write a

Java

Answer these questions by looking things up in the Java API.

Use the following format when making work: copy the task and write a code just in the next line.

I. Using the String class

Given the declarationString s = "letterhead";

  1. Write the expression to find index of the character 'h'.
  2. Write the expression to retrieve the character 'r'from the String.
  3. Write the expression to get the substring "ette".
  4. Write the expression to find the index location of the last 'e'.

II. Using the Math class

  1. Write the expression to calculate e1.7
  2. Write the expression to find the larger of two valuesxandy
  3. Write the expression to generate a random number in the range [0.0, 1.0)
  4. Write the expression to generate a random number in the range [0.0, 20.0)(hint: this won't be a new method, but will require some math after you make the call).
  5. Write the expression to generate a random number in the range [5.0, 6.0)(same hint as before).
  6. Write the expression to generate a random number in the range [10.0, 15.0)(think about combining the 2 steps from 4 and 5).
  7. Write the expression to generate a random integer in the range [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

III More searching through the API

  1. Create a statement to instantiate a Point object with coordinates (3, 4) and binding it to an appropriate reference variable.
  2. What package do you need to import to use a Point object?
  3. What are the coordinates of a Point object if you don't specify any? (0,0)
  4. Repeat exercises 3-6 from the Part2 using the Random class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!