Question: Consider the following instance variable and method. private String [ ] words; public void mystery ( int n ) { for ( int k =

Consider the following instance variable and method.
private String[] words;
public void mystery(int n)
{
for (int k = n; k < words.length -1; k++)
{
words[k]= words[k +1].substring(0, n);
}
}
Assume that words has been initialized with the following values.
{"dragon", "ogre", "troll", "goblin", knight}
Which of the following represents the contents of the array words as a result of the call mystery(1)?
Group of answer choices
{d,o,t,g,knight}
{o,t,g,k}
{dragon,t,g,k,knight}
{k}
{g,k}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!