Ask Question

I. Given the following Java code fragment, what is output? int a, b; String c, d, e; String x = new String ("I LOVE"); String y = "java!"; a = x. length (); System. out. println ("1) " + a); b = y. length (); System. out. println ("2) " + b); c = y. toUpperCase (); System. out. println ("3) " + c); d = x. toLowerCase (); System. out. println ("4) " + d); e = x. concat (y); System. out. println ("5) " + e);

+5
Answers (1)
  1. 4 July, 19:37
    0
    Output: The question segment gives the following output--

    1) 6

    2) 5

    3) JAVA!

    4) i love

    5) I LOVEjava!

    Explanation:

    "1) 6" comes because "6" is the length of "I LOVE" which is the value of "x" variable and "x. length () " statement gives the length of the value of "x" variable which is stored on "a" variable and "a" will be printed with "1) " symbol. "2) 5" comes because "5" is the length of "java!" which is the value of "y" variable and "y. length () " statement gives the length of the value of "y" variable which is stored on "b" variable and "b" will be printed with "2) " symbol. "3) JAVA! " comes because "JAVA!" is the upper case letter of "java!" which is the value of "y" variable and "y. toUpperCase () " statement change the value from lower case to uppercase of the value of "y" variable which is stored on "c" variable and "c" will be printed with "3) " symbol. "4) i love " comes because "i love" is the lower case letter of "I LOVE" which is the value of "x" variable and "x. toLowerCase () " statement change the value from uppercase to lowercase of the value of "x" variable which is stored on "d" variable and "d" will be printed with "4) " symbol. "5) I LOVEjava! " comes because " I LOVEjava! " is the mixed value of the "x" and "y" variable. It prints because "x. concat (y); " statement combines the x and y value and stored in an "e" variable and "e" will be printed with "5) " symbol.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “I. Given the following Java code fragment, what is output? int a, b; String c, d, e; String x = new String ("I LOVE"); String y = "java!"; ...” 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