Question
Consider the following Java code: public class
SubstringDryRun { Â Â public static void main(String[] args) { Â Â Â Â String s = "Programming"; Â Â Â Â String s1 = s.substring(3, 7); Â Â Â Â String s2 = s.substring(s.indexOf('g') + 1); Â Â Â Â System.out.println(s1 + s2); Â Â } } What will be the output of this program?Solution
Correct Answer: A s = "Programming" s1 = s.substring(3, 7): P-0, r-1, o-2, g-3, r-4, a-5, m-6, m-7, i-8, n-9, g-10. substring(3, 7) extracts characters from index 3 up to (but not including) 7. So, s[3]s[4]s[5]s[6] which is "gram". s.indexOf('g') is 3. s2 = s.substring(s.indexOf('g') + 1) is s.substring(3 + 1) which is s.substring(4). s.substring(4) extracts characters from index 4 to the end. So, s[4]s[5]s[6]s[7]s[8]s[9]s[10] which is "ramming". s1 + s2 = "gram" + "ramming" = "gramramming".
What is cohesion in software engineering?
Which statement is FALSE regarding Zener diode?
What is a common disadvantage of greedy algorithms?
What is the primary function of the Accumulator (AC) in a computer system?
Which of the following programming language can be used to process text data for the requirements in various textual data analysis?Â
Which of the following statement is INCORRECT related to mysql_list_tables() function ?
What is the primary disadvantage of using an array as a data structure?
State True or False
Semi-structured data  is data that does not conform to a data model but has some structure. It lacks a fixed or rigid sc...
What does the Hamming distance between two binary strings represent?
If a class inheriting an abstract class does not define all of its function then it will be known as :