Ask Question
14 February, 21:49

Suppose we have a String object called myString. Write a single line of Java code

that will output myString in such a way that all of its characters are uppercase.

+4
Answers (1)
  1. 14 February, 22:51
    0
    myString=myString. toUpperCase ();

    Explanation:

    In java to change all characters of a string to upper case we use. toUpperCase () method. It will convert string to upper case.

    Implementation in java.

    import java. util.*;

    class Solution

    {

    public static void main (String[] args) throws java. lang. Exception

    {

    try{

    Scanner scr=new Scanner (System. in);

    System. out. print ("Enter a string:");

    String myString=scr. nextLine ();

    myString=myString. toUpperCase ();

    System. out. println ("string in upper case : "+myString);

    }catch (Exception ex) {

    return; }

    }

    }

    Output:

    Enter a string:hello

    string in upper case : HELLO
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Suppose we have a String object called myString. Write a single line of Java code that will output myString in such a way that all of its ...” 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