Ask Question
27 January, 00:11

Write a static boolean method named beginsWithZ. It should accept a String object as a parameter. It should return true if the first character in the String is either of two characters: a capital 'Z', or a lowercase 'z'. (Note: Check the parameter for a null value, and for an empty string. Nulls and empty strings do not start with an 'z'.)

+5
Answers (1)
  1. 27 January, 03:13
    0
    public static boolean beginsWithZ (String word) word. charAt (0) = = 'z')

    return 1;

    else

    return 0;

    Explanation:

    This method is a boolean method, meaning it returns true if the string begins with Z or z and false otherwise. So:

    The Java command charAt () let's you find the character at each position of the string, so i use it.

    public static boolean beginsWithZ (String word)
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a static boolean method named beginsWithZ. It should accept a String object as a parameter. It should return true if the first ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers