Answer:
// here is code in java.
import java.util.*;
// class definition
class Solution
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// scanner object to read input from user
Scanner scr=new Scanner(System.in);
// string variables
String st1,st2;
System.out.print("enter the first string:");
// read the first string
st1=scr.nextLine();
System.out.print("enter the second string:");
// read the second string
st2=scr.nextLine();
// part (a)
// find length of each string
System.out.println("length of first string is: "+st1.length());
System.out.println("length of second string is: "+st2.length());
//part(b)
// concatenate both the string
System.out.print("after Concatenate both string: ");
System.out.print(st1+st2);
// part(c)
// convert them to upper case
System.out.println("first string in upper case :"+st1.toUpperCase());
System.out.println("second string in upper case :"+st2.toUpperCase());
}catch(Exception ex){
return;}
}
}
Explanation:
Read two strings st1 and st2 with scanner object.In part a, find the length of each string with the help of .length() method and print the length.In part b, concatenate both the string with + operator.In part c, convert each string to upper case with the help of .toUpperCase() method.
Output:
enter the first string:hello
enter the second string:world!!
length of first string is: 5
length of second string is: 7
after Concatenate both string: hello world!!
first string in upper case :HELLO
second string in upper case :WORLD!!