Ask 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 characters are uppercase.

+3
Answers (1)
  1. 19 March, 05:13
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers