✏️ Explanatory Question

State the method that:

  1. Converts a string to a primitive float data type.
  2. Determines if the specified character is an uppercase character.

👁 82 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

Here are the methods for the specified tasks:

  1. Converts a string to a primitive float data type:

    • Method: Float.parseFloat(String s)
    • Description: This method converts a String to a primitive float. For example

String str = "3.14";
float f = Float.parseFloat(str); // f will be 3.14f

Determines if the specified character is an uppercase character:

  • Method: Character.isUpperCase(char ch)
  • Description: This method checks if the specified character is an uppercase letter. For example:

char ch = 'A';
boolean isUpperCase = Character.isUpperCase(ch); // isUpperCase will be true