Question: This is java code. public class Lamb { String[] array = { Mary, had, a, little, lamb, null , null , null , null ,

This is java code.

public class Lamb

{

String[] array = { "Mary", "had", "a", "little", "lamb",

null, null, null, null, null };

int size = 5;

void insert (String word, int index) {

}

/** Print the words in array from 0 to size-1. */

void print () {

for (int i = 0; i < size; i++)

System.out.print(array[i] + " ");

System.out.println();

}

public static void main (String[] args) {

Lamb lamb = new Lamb();

lamb.print();

lamb.insert("very", 3);

lamb.print();

lamb.insert("only", 1);

lamb.print();

lamb.insert("Doctor", 0);

lamb.print();

lamb.insert("chop", 8);

lamb.print();

lamb.insert("eaten", 4);

lamb.print();

System.out.println("Final sentence should be:");

System.out.println("Doctor Mary only had eaten a very little lamb chop");

}

}

The output is:

Mary had a little lamb Mary had a little lamb Mary had a little lamb Mary had a little lamb Mary had a little lamb Mary had a little lamb Final sentence should be: Doctor Mary only had eaten a very little lamb chop

!!!!!!!! Make some changes in the original code ,then your output should be:

Mary had a little lamb Mary had a very little lamb Mary only had a very little lamb Doctor Mary only had a very little lamb Doctor Mary only had a very little lamb chop Doctor Mary only had eaten a very little lamb chop Final sentence should be: Doctor Mary only had eaten a very little lamb chop

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!