Write a java program to find the sum of elements of the array recursively.
1. Suppose you have the following array: {11, 22, 33, 44, 55, 66, 77}. Write a java program to find the sum of elements of the array recursively.
2. Suppose a program builds and manipulates a linked list:
What two special nodes would the program typically keep track of? Describe two common uses for the null reference in the node of the linked lists.
3. Consider the following Java Code:
What is the output when this code is executed?
import java.util.LinkedList;
import java.util.ListIterator;
class Main {
public static void main(String[] args) {
LinkedList<String> myLList = new LinkedList<String>();
myLList.addFirst("Ali");
myLList.addFirst("Omar");
myLList.addLast("Sara");
ListIterator<String> myiterator = myLList.listIterator();
myiterator.next();
myiterator.next();
myiterator.add("Reem");
myiterator.previous();
myiterator.add("Ahmad");
myiterator.add("Khaled");
myiterator.previous();
myiterator.remove();
System.out.println(myLList);
myiterator.next();
myiterator.next();
System.out.println("MyList Backward iteration :");
while(myiterator.hasPrevious())
System.out.println(myiterator.previous());
System.out.println("---------------------");
}
}
Step by step
Solved in 5 steps with 1 images