Question: Questions: a) Create the constructor in class Word. b) Draw the object referred to by reference w. c) Which output is generated if class Word

Questions:
a) Create the constructor in class Word. b) Draw the object referred to by reference w. c) Which output is generated if class Word is used like this?
char[] v1 = {'L', 'i', 'g', 'h', 't'}; Word w1 = new Word (v1); char[] v2 = {'L', 'o', 'v', 'e'}; Word w2 = new Word (v2); w1.combine (w2);
System.out.println (w1);
Please explain in detail how to think when tackling questions like these! :)
The class word represents a word. Characters in the word are stored in a sequence of linked nodes. class Word private class Node public char c; public Node next; public Node (char c) this c c; this next null the first node in the node sequence private Node first null Word creates a word from an array of characters code is missing here public String to String StringBuilder sb new StringBuilder Node node first; if (node null) while (node.next null) sb.append (node.c) i node node.nexti sb.append (node c) sb.append ("1") return sb. to String public void combine (Word w) if (w. first null) Node n1 this first Node n2 first if (this first null) this. irst new Node (n2.c) nl this. first; n2 n2.next while (nl.next null) nl ni next; while (n2 null) nl .next new Node (n2. c) i n1 nl .next; The class word is used like this: char CJ v 'L 'i', f 'e' Word W new Word (v); System Rpiniin (W); When this code fragment is executed, the following output is generated: [Life]
Step by Step Solution
There are 3 Steps involved in it
a Constructor for Word Class The Word class constructor is missing It needs to take a char array and ... View full answer
Get step-by-step solutions from verified subject matter experts
