Solve Please Very Quickly,
March 16, 2010 at 7:13 PM
CSE111 Lab 8 – Exceptions, Applets, JavaFX and two IDEs
Task 1
Create an array of size 5. Try to store 100 to the index 21 of the array. It should give you a runtime error. Note the first line of the error that was given.
Task 2
In your main method, try to divide 1 by zero. Note the first line of the error that was given.
Task 3
import java.util.Scanner; class Task3{ public static void main(String[]args){ Scanner sc=new Scanner(System.in); int x,n=sc.nextInt(); int a[]=new int[n];
a[5]=99; x=n/0; } }
Modify the program above to handle exception ‘ArithmeticException’ and ‘ArrayIndexOutOfBoundsException’ using try, catch and finally (to print a message “Final Line”) keywords.
Task 4
It is hard to know every error that may occur in advance. Hence, modify your solution to Task 3 to account for all other unknown errors that can be caused from any line of the main method. For example, 5.0 as input for the array size.
Task 5
Write a Java Application that will create your own exception ‘NotAnIntegerException’. There will be a method int readInteger( ). This method will take a String form the user. Then it will check if the number was ‘int’ or ‘float’ by checking presence of the decimal point in the input. It will throw an exception when a floating-point number is entered.
Task 6
Prepare an applet that prints hello world or your name. Take help from: http://www.realapplets.com/ Rest will be shown in class
Task 7 Execute MSWord and Dr.Java from your java program Help: http://intekhabsadekin.wordpress.com/2009/03/05/java-runtimegetruntimeexec-will-and-will-not-work/
Task 8
Print hello world or your name using JavaFX
Task 9
Using Eclipse, Take 2 numbers as input, print the sum. See notes.
Task 10
Using NetBeans, Take 2 numbers as input, print the multiplication. See notes.
Notes for Task 9 and 10: Show all screen shots including how to create project, write class, compile, run and test your program.