#7. Linked list - print last node... Extra info/hint? It's freeGiven the following class for the nodes in a linked list:public class Node { ... public Node getNext() {...} // return next field public int getData() {...} // returns data}Assuming that the variable head points to (i.e. contains the address of) the first node of a linked list, write thestatement(s) to print the data value in the last node of the linked list to the console. The format of the output must be"Last node has: n" where n is the number.You may declare additional variables and assume that there is at least one node in the linked list.Sample console I/O execution sequenceLast node has: 35Type or paste your response to this question here#4. Linked list - every other node... Extra info/hint? It's freeI have a program which prompts a user for an integer (n) and then builds a linked list with numbers between 1 and n.For example, if the user enters 5, the program will build a linked list with 1 through 5, and display it as 5, 4, 3, 2, 1.I would like to also display every other node data in this program i.e. 5, 3, 1 for the above example.Given the following class for the nodes in a linked list:public class Node { ... public Node getNext() {...} // return next field public int getData() {...} // returns data}Assuming that the variable head points to (i.e. contains the address of) the first node of the linked list, write thestatement(s) to print the data value in every other node of the linked list to the console. For example if the list has 5->4->3->2->1, the output should be 5 3 1 i.e. the numbers only with spaces in-between.If the list is empty 0 size), you code should not print out anything.You may declare additional variables and assume that the list may have any number of nodes including zero.If the list is empty, do not print anything, otherwise print the data separated by white spaces.Sample console I/O execution sequenceEnter list size: 5List data: 5 4 3 2 1Every other data: 5 3 1Enter list size: 0List data:Every other data:Type or paste your response to this question here#5. Single linked list - average... Extra info/hint? It's freeFor this problem, I have a complete linked list program which supports the following commands from the user:insert, display, delete, average, find, insertBefore, insertAfter. insert allows them to insert a number into the current list,display will display the numbers in the current listetc.The program is complete except that I have removed the body of the method for averaging the numbers in the linked list..Given the following class for the nodes in a linked list:public class Node { ... public Node getNext() {...} // return next field public int getData() {...} // returns data}Assuming that the variable head points to (i.e. contains the address of) the first node of a linked list, write thestatements to find the average of all data values in the linked list. For example, average() will return something like"avg: 2.67" or "Empty". The average should be returned as a string with exactly two digits of decimal accuracy, orEmpty if the list is empty. Your statements will be inserted inside a method like the following: public String average() { // Whatever statements you provide in response to this question will // be inserted here BY THE SYSTEM and then compiled and tested as part of // a larger program which does many other things with the linked list }Sample console I/O execution sequenceLinked list code sample. Options are:(insert, display, delete, average, find, insertBefore, insertAfter)What would you like: insert 4inserted 4What would you like: insert 1inserted 1What would you like: insert 3inserted 3What would you like: averageavg: 2.67What would you like: delete 3deleted 3What would you like: delete 4deleted 4What would you like: delete 1deleted 1What would you like: averageEmptyWhat would you like: ExitBye