Solved by verified expert:Build on the examples given in 1009-classwork.zip.1.Explain why the following code will not compile:import StackGeneric.*;
public class Test0 {
public static void main(String [] args){
Stack
for( int i = 0 ; i < 5 ; i++) {
st.push(i);
}
st.push(5);
System.out.println(st.pop());
}
}
2.Explain why the following two examples throw an exception when run.import StackGeneric.*;
public class Test {
public static void main(String [] args){
Stack
int n = st.pop();
}
}
import StackGeneric.*;
public class Test2 {
public static void main(String [] args){
Stack
for( int i = 0 ; i < 1000 ; i++) {
st.push(i);
}
st.push(5);
}
}
3.Read the Java tutorial on Exceptions, up to and including the section on finally blocks.4.In Problem 2. above, both examples threw ArrayIndexOutOfBoundsException exceptions. Using the following template, modify the methodpublic void push(Integer value)so that if pushing results in exceeding the maximum size of the array, the ArrayIndexOutOfBoundsException is caught, an appropriate message is printed, but the program continues, though the requested action is not completed.Template:try{ /* … */ }
catch(ArrayIndexOutOfBoundException e){ /* … */ }
5.In the above example, I referred to the method “push” using the full signature. Why is this good practice, rather than just writing “push”?6.Complete the problem described in the picture slide 1(1009 Information) in the folder 10/09.
1009_classwork.zip
Unformatted Attachment Preview
…
Purchase answer to see full
attachment
You will get a plagiarism-free paper and you can get an originality report upon request.
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more