Ask Question
4 May, 20:14

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. 4 May, 20:24
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers