Step 1: Recall how substring() works in Java.
In Java, substring(beginIndex, endIndex) starts from beginIndex and goes up to endIndex - 1.
This means the starting index is included, but the ending index is excluded.
Step 2: Write the indices of the word ACKNOWLEDGEMENT.
Let us mark the positions of the letters:
\[ \begin{array}{ccccccccccccccc} A & C & K & N & O & W & L & E & D & G & E & M & E & N & T \\ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 \end{array} \]
We want the word NOW. This begins from:
\[ N = 3 \]
and includes:
\[ O = 4,\quad W = 5 \]
To stop after W, the ending index must be:
\[ 6 \]
because index 6 is excluded.
Step 3: Form the substring. So,
\[ \texttt{"ACKNOWLEDGEMENT".substring(3,6)} \]
will give:
\[ \texttt{"NOW"} \]
Hence, the correct number to fill in the blank is 6.
Step 4: Conclusion.
Therefore, the correct Java statement is:
\[ \texttt{"ACKNOWLEDGEMENT".substring(3,6)} \]
So, the correct answer is 6.
Final Answer: 6
document.addEventListener("DOMContentLoaded", function () { renderMathInElement(document.body, { delimiters: [ { left: "\\[", right: "\\]", display: true }, { left: "\\(", right: "\\)", display: false } ] }); });
Give the output of the following Java program segment:
String a[] = {"Atasi", "Aditi", "Anant", "Amit", "Ahana"};
System.out.println(a[1].charAt(1) + "*" + a[2].charAt(2));
The output of the above statement is:
Assertion (A): The substring() method modifies the original String.
Reason (R): The substring() method can extract part of a String from a specific index.
नीचे दिए गए चित्र को ध्यान से देखिए और चित्र को आधार बनाकर कोई लेख, घटना अथवा कहानी लिखिए जिसका सीधा व स्पष्ट संबंध चित्र से होना चाहिए। 