KnowledgeBoat Logo
|

Computer Applications

What will be the output of the following statement?

String s = "JavaProgramming";
System.out.println(s.substring(4, 11).toUpperCase());
  1. Programm
  2. PROGRAMM
  3. PROGRAM
  4. program

Java

Java String Handling

4 Likes

Answer

PROGRAM

Reason — In the string "JavaProgramming", indexing starts at 0. substring(4, 11) extracts characters from index 4 to 10, which is "Program". Calling .toUpperCase() converts it to "PROGRAM".

Answered By

1 Like


Related Questions