practiceException

practiceException - try { System.out.println("Welcome...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Book -title:String -price:double -bookId:int +Book(title:String,price:double,bookId:int) Practice Exceptions CSE205 First Name (Print)___________________ Last Name _________________ Date ________ 1. What is displayed on the console when the following program is run? class Test { public static void main(String[] args) { try { System.out.println("Welcome to Java"); int[] a = new int[10]; a[10] = 1; System.out.println("Welcome to HTML"); } finally { System.out.println("The finally clause is executed"); } } } 2. What is displayed on the console when the following program is run? class Test { public static void main(String[] args) { try { System.out.println("Welcome to Java"); int[] a = new int[10]; a[10] = 1; System.out.println("Welcome to HTML"); } catch (Exception ex) { System.out.println("There is an exception”); } finally { System.out.println("The finally clause is executed"); } } } 3. What is displayed on the console when the following program is run? class Test { public static void main(String[] args) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: try { System.out.println("Welcome to Java"); int a = new int[10]; a[0] = 1; System.out.println("Welcome to HTML"); } finally { System.out.println("The finally clause is executed"); } } } 4. What happens if you attempt to open a nonexistent file using FileInputStream? 5. What happens if you attempt to open a nonexistent file using FileOutputStream? 6. What happens if you attempt to store an object that is not an instance of Serializable? 7. Assume that you will want to save, using object serialization, a Book object in a file. Write a class definition (Book.java) for Book class using the following UML class diagram. This class has only one method, a constructor that assigns values to each instance variable. Then write a complete Java program (driver class with a main() method) to instantiate an Book object with some title, price and bookId (you can decide on them) and store it in a file called “book.dat”....
View Full Document

This note was uploaded on 06/11/2009 for the course CS 205214 taught by Professor Balasooriya/kouvetakis during the Spring '09 term at ASU.

Page1 / 2

practiceException - try { System.out.println("Welcome...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online