Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

What conflicts of interest had to be resolved?

Answered: 1 week ago