Project #67193 - 3 Java Discussion Questions

Answer the 3 Discussion Questions ONLY Below.  DO NOT ANSWER QUESTION 1 or 2. 

 

MAX BUDGET $70

 

 

Question #1: Think of a programming task--other than the individual or team assignments in this course--in which you would choose to use an exception handler. Write the code for the try-catch block. Explain the activity and your code. (DO NOT ANSWER QUESTION #1 use as reference for Discussion Question #1.)

 

 

DISCUSSION QUESTION #1.  Respond to Michelle’s answer (Below)  to question #1(Above) 

 

A few reasons exceptions can occur are if a user inputs invalid data, a file cannot be accessed or found ,  and JVM has run out of memory. There are three types of exceptions in Java, Checked, Runtime and Errors. An exception handler would be used to handle these unexpected exceptions thrown.

All exception classes are subtypes of the Exception class. The Exception class is a subclass of the Throwable class. Other than the Exception class there is another subclass called Error which is derived from the Throwable class. A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code

 

The following is an array is declared with 2 elements. The code tries to access the 4th element of the array which throws an exception.

public class ExceptionClassTest

{

   public static void main(String args[])

   {

      Try

         {

         int a[]=newint[3];

         System.out.printf("Access element three :"+ a[4]);

         }

                 catch(ArrayIndexOutOfBoundsException e)

                 {

                          System.out.printf("Exception thrown  :"+ e);

                 }

      System.out.printf("\nOut of the block");

   }

}

 

Question #3: What are the advantages and disadvantages of sequential and random access files? 

Provide an example in which a sequential file is a better choice than a random access

file. Explain why. Provide an example in which a random access file is better than a

sequential file. Explain why (DO NOT ANSWER QUESTION #3 use as reference for

Discussion Question #2 & #3.)

 

 

DISCUSSION QUESTION #2Respond to Michelle’s answer (Below)  to question #3 (Above) 

 

Random-access files, , sometimes call direct access, allows you to read and write data anywhere within the file. Sequential-access file only enables access to read or write in sequential order starting at the beginning of the file. Sequential-access file is faster but if you do not always need access to the files sequentially then this is not the best option.

Sequential-access would  be useful for short lists that need to be updated or modified often. I use to manage an Access database, I would pull sales data from the Davta Warehouse (ODS) every Sunday morning. I would dump it in the access database. I then to update certain files in one of the systems. It was sequential. It would pull up the names of the 10 accounts in the same order every time. This made it easy for me, I knew what order I was going to update and made this painful project a little easier.

 

Random-access although slower is much more practical for larger databases or programs. Users would be able to access just what they are looking for rather than going through everything until they get to what they were longing for.

 

DISCUSSION QUESTION #3  Respond to Victor’s answer (Below)  to question #3 (Above) 

 

This particular question is one I don't have personal experience with. But from what I've read, I've been able to determine that there is quite a big difference between sequential and random access files. In a sequential file, the information passes through predictably, always in the same order or sequentially as per its namesake. This makes it faster than random access. In a random access file, there is a higher amount of seek operations, meaning that it will often take longer than accessing data through a sequential file. It's a good idea to use a disk with higher seek times if using Random Access.

 

If you know you'll always have to access data in the same order, for instance in my job account numbers are created in sequential order numerically, then accessing the file sequentially would be most beneficial. If using a short list of account numbers, (as I do when working collections) you'll always know where that particular account number lies, and modify its contents as needed.

 

 

When dealing with a longer list, such as an overview of the entire database of accounts within the financial institution, random access would function better. It would be a pain to start from account number 100 when trying to reach account number 9054682.

Subject Computer
Due By (Pacific Time) 04/18/2015 08:00 pm
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy