Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java 4- Write a generic method that takes an array of some class type as an argument and returns the last element of the array.
java
4- Write a generic method that takes an array of some class type as an argument and returns the last element of the array. The method should limit the base type of the array to those classes that implement the Comparable interface (i.e., define a bound for the type parameter). 5- Write a code fragment that creates an ArrayList of Integer called 'myList and initializes it with the first 10 multiples of 5 (0,5,10,15,20,25,30,35,40,45). Traverse 'myList' to find the sum of all the even numbers and then display the sum. 6-Write a code fragment that deletes one of the values, say 35, from the ArrayList defined in problem 5. Ask the user to type in that value at the keyboard. 7- Write a static method that takes a singly linked list of type Integer as an argument, and returns the sum of the values in the last two nodes. The method will return-1 if the list has less than two nodes (see the Single-Linked List class given in the textbook). 8- Add a method called 'removeSecond' to the class DoublyLinked List given in the textbook. This method will remove the second node from the doubly linked list if the list has at least two nodes. Otherwise it will throw an Exception of type IllegalState Exception. 9- Use a stack to convert the following infix expression to its equivalent postfix expression. Show the contents of the stack prior to each pop operation. 5+38/2-7 10- Write a client method named 'reverse that takes a Stack of Integers as an argument and reverses the order of elements on the Stack. Do this using just the stack operations defined in the stack interface (see page 149 of your textbook). You can define additional stacks inside your method in order to accomplish this task Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started