New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

CSC 122 Exam Review Notes

by: AnnMarie

CSC 122 Exam Review Notes CSC 122


GPA 3.028

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

The notes from Lecture 1 to 11 will assist with studying for the mid-term. They are setup as Q&A.
Intermed Computer Programming
Study Guide
50 ?




Popular in Intermed Computer Programming

Popular in ComputerScienence

This 24 page Study Guide was uploaded by AnnMarie on Monday April 18, 2016. The Study Guide belongs to CSC 122 at Louisiana Tech University taught by MULMI, SANGAM in Spring 2016. Since its upload, it has received 24 views. For similar materials see Intermed Computer Programming in ComputerScienence at Louisiana Tech University.

Similar to CSC 122 at LA Tech

Popular in ComputerScienence


Reviews for CSC 122 Exam Review Notes


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 04/18/16
March 18: CSC 122 Lecture 1 What is inheritance in Java? Inheritance, in Java, is the concept of a general class that passes down properties to a specialized class. In other words, it allows us to define one class as an extension of another. What is a has-a relationship? We originally started learning about objects and how to use methods to make objects do things. We created classes that created objects and we can say that this is a has-a relationship bclasse a has a object. The following lines of code display a has-a relationship: Planet a = new Planet(); a = getName(); What is a is-a relationship? Earth is a planet – this is an example that we used in class to explain that the Planet class is the superclass and Earth is the subclass of Planet. Inheritance is often called an is-a relationship because a subclass is a specialization of a superclass. How do you use inheritance in Java? In Java, you will use the extends keyword to specify that this class is a subclass of the superclass. The following code segment illustrates this. class Earth extends Planet The class Planet is called the parent class or superclass – a class that is extended The class Earth is called the child class or subclass – a class that extends (inherits from) another class. The fields and methods from the superclass are inherited also when you declare a class to be a subclass of another class. Can you use multiple inheritance in Java? Java does not support multiple inheritance, but you can use inheritance hierarchy to simulate multiple inheritance. This multiple inheritance can be called inheritance hierarchy – classes that are linked through inheritance relationships. An example of this could be the classification of species used by biologists. The following diagram displays a small part of the inheritance hierarchy of animals. As you can see, the Tiger class is a subclass of Cat which is a subclass of Mammal which is the subclass ofAnimal. The principle is simple: inheritance is an abstraction technique that allows us to categorize classes of objects under certain criteria and helps us specify the characteristics of these classes. What is the purpose of access modifiers? Access modifiers such as - Public, Private , and Protected - allow access or deny access to variables and methods of one class from another class . Private variables and methods can only be accessed from within the class that they are declared. Public variables and methods can be accessed by other classes, but we do not make instance variables public. We allow methods to be public to allow other class to invoke actions on objects. The rules of privacy still apply to superclasses and subclasses because a subclass cannot access private members of its superclass. Protected allows only the predecessors of inheritance to access the variables. What are the properties of inheritance? 1. Sub-classes inheritance all the properties of the general class except Private access modifiers. 2. Sub-classes are specialized classes of the general class 3. Sub-classes have a is-a relationship with the general class. What is overriding? Overriding is the concept of taking a method that was inherited from the general class and changing it to have a different implementation. You can use the super. to implement a method that is in the general class once the method was overridden. It is suggested to put @override above the overridden method to make it known that you did the override on purpose. Why do you use inheritance? Inheritance provides several advantages such as – avoiding code duplication, code reuse, easier maintenance, and better (easier) extendibility. By using inheritance we can simplify a set of classes that have the same instance variables and methods instead of having lots of code duplication which makes it harder to maintain, harder to extend, and difficult to reuse. Do all the classes have constructors with class inheritance? Yes, a subclass needs to call the constructor of the superclass. The following displays how you would use the constructor of the superclass in the subclass. However, if you do not use the explicit call the constructor of the superclass, the compiler will do this automatically. But if the constructor of the superclass takes a parameter you have to explicitly call the constructor by super(parameter, parameter, ect.); else it will produce an error. class SolarSystem{ public SolarSystem(){ } } class Earth extends SolarSystem{ public Earth(){ super(); } } If you use a parameter with the super() when the general class constructor does not take a parameter, the class will not compile. After inheritance can you use a different type from the super type? Variables may hold objects of their declared type or of any subtype of their declared type.Asubtype is one that is defined by its subclass of a superclass. The following segment of code illustrates legal typing: SolarSystem s = new SolarSystem(); s = new Planet(); s = newAsteroids(); The type of a variable declares what it can store. Declaring a variable of type SolarSystem states that this variable can hold Planets andAsteroids because these are parts of a Solar System. “This principle is known as substitution. In object-oriented languages, we can substitute a subclass object where a superclass object is expected, because the subclass object is a special case of the superclass (page 294).” What is type casting? You can type cast to change the type of a variable or object with (type to change to) in order to force the compiler to compile. The following line of code displays an instance that you will want to use type casting because the complier will produce an error. SolarSystem s = new Planet() Planet p = s; // this will give an error You will will want to change the second line of code to Planet p = (Planet) s for this to work. However this is something to avoid unless necessary. But if you have to use type casting is is suggested to use the instanceof to check to see if the type you are changing to with the type casting is an object of that type. if(s instanceof Planet){ Planet p = (Plant) s;} March 20: CSC 122 Lecture 2 What is subtype/substitution? Subtyping allows an object of a subclass to be used wherever its superclass type is required. In other words, the type defined by a subclass definition is a subtype of the type of its superclass. Due to this the typing rule can be revised to state: “a variable can hold objects of its declared type or of any subtype of its declared type(page 293).” The following assignments are legal: SolarSystem s = new Planet(); s = newAstroids(); The type of the variable declares what it can store. Declaring a variable of the type SolarSystem states that this variable can hold solar systems. Because a planet is a part of a solar system, it perfectly legal to store a planet in a variable that is intended for solar systems. This principle is known as substitution – is practice of using a subclass object where a superclass object is expected. However, we cannot use a superclass object where a subclass object is expected. This will give an error message and no compile. Can you use subtype on methods? Yes, you can pass a parameter of a superclass to a method. The following sample of code displays passing a superclass as a parameter to the constructor method. public class Planet{ public void addPlanet (SolarSystem s) { } } Where s is a polymorphic variable. What are polymorphic variables and are all variables that hold objects polymorphic? Polymorphic variables are variables that can hold objects of different types.Almost all variables are considered to be polymorphic. However the exception to this are variables that hold primitive types. What are wrapper classes? Primitive types can be transformed into objects to allow Primitive types to be stored in a collection. The following are some of the wrapper classes: Boolean Character Integer You can create an object of integer by the following call: num = new Integer(10); The wrapper classes are also polymorphic because now they store an object that is an Integer, Character, Boolean, etc. What is autoboxing and unboxing? Autoboxing is performed automatically when a primitive-type value is used in a context requiring a wrapper type. The following sample of code displays a primitive int variable a in an Integer object: Integer iwrap = new Integer(a); And now iwrap can be easily stored in a collection such asArrayList<Integer>. The reverse operation of autoboxing is unboxing. Unboxing is applied when a wrapper-type value is passed as a parameter to a method that expects a primitive-type value and when stored in a primitive-type variable. The following sample of code displays the retrieval of the first value in a collection called markList and is stored in a primitive-type variable called firstMark: int firstMark = markList.remove(0); One thing that should be mentioned is that when storing a wrapper type object into a collection the collection still requires the type to be declared using the wrapper type (e.g.,ArrayList<Integer>). Do classes inherit from Object? Yes, all classes inherit from the superclass of Object implicitly if they have no superclass declared explicitly. There are two purposes that having a common superclass for all objects – first, we can declare polymorphic variables of type Object to hold any object; second, the Object class can define some methods that are then automatically available for every existing object. What does it mean when initialization of a new instance is static? We call the declared type of the variable the static type, because it is declared in the source code – the static representation of the program. What does it mean when an instance of an object is dynamic? We call the type of the object stored in a variable the dynamic type, because it depends on assignments at runtime – the dynamic behavior of the program. What is dynamic method lookup? Dynamic lookup is the process of looking up a method during runtime through the inheritance hierarchy. However, a variable will use the superclass variable due to variables being static. What is overriding and how do you override a method? Overriding is the situation where a method is defined in a superclass, and a method with exactly the same signature is defined in the subclass. To override a method you will use the same method header and parameters, but the body of the method will be different. The overriding method take precedence for method calls on subclasses of objects. Should you use inheritance whenever possible? You should use inheritance when multiple classes use the same variables and methods. What is the difference between overriding and polymorphism? Overriding is a type of polymorphism that when you call a method on an object and the method in the subclass with the same signature as the one in the superclass is called. Polymorphism is where you are not sure of the objects type at runtime and the most specific method is called. In other words, polymorphism is the concept that makes use of overriding, overloading, parametric and dynamic method binding to make it happen. When you want to compare two objects what method do you use? You will use the isEqual() method when comparing two objects because the == only checks to see if the objects are in the same memory location and will return false because they are not. What does static binding and dynamic binding apply to? Static binding applies to variables and dynamic binding applies to methods at runtime. What is abstraction? Abstraction, in Java, is the general structure (organization) of a class that does not implement anything. The following is an example of declaring an abstract class using the abstract keyword. abstract class Planet{ abstract public void a(); } If a subclass inherits from an abstract class, the subclass needs to provide the implementation for that class. You do not need to provide the implementation if the subclass is also abstract or if you extend the subclass because the extended subclass will implement the class. Does overriding and polymorphism apply with abstraction? Yes, because you have to override methods. Can abstract classes be final? Yes, but the final abstract class cannot be extended upon. Can abstract classes be static? Can abstract methods be final? No, because the concept of abstract is that the method will be overridden. Can abstract methods be static? No, because if a method is static it means that the method can be called anywhere without implementation. Do abstract classes have constructors? Yes, but you cannot create an instance of that class. Can you have a class abstract without the keyword abstract? Yes. Can you have a abstract method in a class that is not abstract? No. What are interfaces? Interfaces are similar to abstract classes because they contain only abstract methods. You can declare an interface with the following line of code: interface Planet{ public abstract void a(); } The public abstract can be explicitly declared or you can leave it out of the method and the system will implicitly declare it for you.Aclass can implement more than one interface with the keyword implements. If it is an interface everything is abstract. If a variable is created within an interface it needs to public, static, or final. March 22: CSC 122 Lecture 3 Can we have variables with interfaces? Yes, but they have to be public, static, or final. Do interfaces have constructors? No, interfaces do not have constructors because they are all abstract classes. Can you have inheritance with interfaces? Yes, you can have inheritance with interfaces. When do you want to use interface? You want to use interface during software development to assist with designing a class without having to implement methods meditatively. You will also want to use interface when you want to subtyping with multiple objects without having to have an inheritance hierarchy. Think of an group project that uses all the key concepts of object-orientation programing. March 30: CSC 122 Lecture 4 Program Assignment: The following will be the data for 20 students: major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits;major, name, age, credits; You will want to store the student into an object and then store it into anArrayList. Then you will use an iterator to print the list of students in theArrayList. Do interfaces create a new type? Yes. Can interfaces have methods? Yes, they can have methods but the method must be public. What is refactoring? Refactoring is taking existing code and cleaning it up to make it cohesive and faster. How would you pass multiple parameter values to a method that only has one parameter declared in the method header? If you have the following method: public int getDays(int m){ } you will need to pass an array to the parameter if you want to have more than one parameter value passed to the method. You can also use variable arguments (…) at the end on int. When invoke the method with multiple values, m will be like an array which its values can be accessed just like an array. The following shows how to invoke the method and how to access the values in m. getDays(1,2,3,4,5,6,7,8,9,10); System.out.println(m[0]); What does args mean in the public main method? Args is arguments which you can pass with the command line when you compile and run the java program with the command line. What is Enumerated types? Enums represent constant value. Before we used Final and uppercase naming to declare constant values. Enums are type safe – keeps the types safe from being incompatible. Always use enums when you are using type constants. You can create an enum by the following: enum Days{ SUN,MON, TUE, WED, THUR, FRI, SAT; } enum is the Java keyword to declare a type safe constant. SUN through SAT are constants. By using enums you can save namespacing, organize your constants better, and prevent type missuse. To assign a value to the constants in enums you do the following: enum Days{ SUN(1), MON(2), TUE(3), WED(4), THUR(5), FRI(6), SAT(6) } Enums can implement interfaces. Private int days; private Days(int days){ this.days=days; } public int getDays(){ return days; } System.out.println(Days.SUN.getDdays()); With enums you can use switch case where you could not use it on objects. Enums inherit from Enum instead of OBJECT. Enums do support polymophism but you can not implement it. What do you have to do create a value argument? ... April 1: CSC 122 Lecture 5 What is GUI? GUI is short for Graphical User Interface, in Java, it allows the user to interact with the program with button, pictures, etc. instead of interacting with a program by invoking commands. What are the elements in GUI? You have a window, title, menue bar, exit button, scroll bar, buttons, etc within a frame. You have a panel, layout, components, and event handlers. With GUI, you need to keep it simple and easy to use. What is a panel? Apanel is a subframe. The idea of panel is to group similar (like) components together to organize the fame. You will have to create label, button, TextArea(multiple line), TextField (single line), ScrollBar, and MenuBar, else they will not appear within the GUI. Are there different types of layouts? There are many layouts that can be implemented within Java. The following are some that are discussed in class. Flowlayout – components will appear left to right in a row until the row is full and then it will go to the next line. Gridlayout – the layout is in a grid layout which components are added by grid. Borderlayout – is like a map with North, East, South, West, and Center. You can have multiple layouts within the same frame. How do you create a GUI in Java? In Java, you will use two classes –AWT and Swing – to create GUI. These are already installed on your computer.AWT contains many classes that can be used to create user interfaces and for painting graphics and images. See JavaAWTAPI. When using AWT, you may encounter issues with other operating systems and thus you would want to use Swing. When you want to create a GUI, you will want to have a solid idea of what layout, components, etc that you want to create. In class, we designed the layout to look like the illustration to the right. The following source code shows how to create simple GUI application that allows the user to increase the text field by 1 each time the button is clicked on. Illustration 1: GUI Design import java.awt.*; import java.awt.event.*; public class SimpleClicker extends Frame implements ActionListener{ public SimpleClicker(){ setTitle("Simple Clicker!"); setSize(600,600); setLayout(new GridLayout(2,1)); final TextField num = new TextField("0"); add(num); Button clicker = new Button("Click Me!!"); add(clicker); clicker.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String initText = num.getText(); int incrementedValue = Integer.parseInt(initText) + 1; num.setText(incrementedValue + ""); } }); setVisible(true); } @Override public void actionPerformed(ActionEvent e){ } public static void main(String[] args){ new SimpleClicker(); } } The class header states that the SimpleClicker class extends Frame which means that the SimpleClicker class inherits the methods and variables of the Frame class. The class also implements the abstract class of ActionListener which allows an action to be performed when the button is clicked on. The first thing that we did was import the java.awt.* class to be able to use the Frame class, Button class, and the TextField class. Timport java.awt.event.* allows use to use theActionListener class. The first thing we see after importing and the class header is the class constructor which has some new method calls that we have not seen before. The setTitle allows you to put a title at the top of your frame. The setSize allows you set the size of the frame in pixels. The setLayout allows you to set the layout of the frame. The TextField num creates a text field which you need to call add afterward to have it added to the frame. Button clicker allows you to create a button, which you need to pass a string as a parameter. The next thing we have is the action listener which adds one to the current number in the textfield each time the button is clicked. .addActionListener(new ActionListener(){}) is the method call that creates a the action listener. However,public void actionPerformed(ActionEvent e) tells the action listener what to do when the the button is clicked on. The Integer.parseInt allows a string that has integers to be converted into integers. The last thing within class body is the setVisible(true) which displays the GUI. The actionPerformed method is overriden because we are implementing it and when we implement interfaces we have to override methods. The main method is used to create the SimpleClicker by invoking its class. What is an anonymous class? When we began to learn about GUI we saw something like the following: class ABC implements ActionListener{ button.addActionListener(new ActionListener(){ @override public void actionPerformed(ActionEvent e){ } }) } the class ActionListener is an anonymous class because Can you have a class inside a class? Yes, you can have a class inside a class. The following displays an example of this: class School{ class History{ } } Can you have a class inside a method? Yes, you can have a class inside a method. The following displays an example of this: class School{ class History{ Public void a(){ class ABC{ } new ABC(); } } When are inner classes useful? They are useful when you have a class that only does one thing, so that you can create the class within the existing class to save time. When the compiler is ran do inner classes create their own .class file? Yes, each class will create their own .class file. This also applies to anonymous classes. What are errors/exceptions? Errors are something wrong with the environment that the program is running in.An example of an error is “Not enough internal memory” or “Stack Overflow Error”. Errors can also be flaws within your program due to the application code being efficient, these errors are known as exception errors.An exception occures during the execution of a program and will provide an message.Afew examples of exception errors are “NullPointerException”, “ArrayIndexOutOfBounds”, “IntermptedException”, “ArithmeticException”, and “fileNotFoundException”. These exeptions come from a class that is being implemented or they come from a specific class that allows you to create exception errors such as Throwable. Inside the Throwable class there are Error and Exception. What are checked/unchecked exeptions? Checked exeptions require an exeption to be created. Unchecked exptions do not require an catch exeption to be created. When a program is executed where do exceptions come from? They come from the Throwable class, even if you are using a different compiler or using the command line to execute the program. How do you handle exeption errors? First, you need to ensure that your code is complete and efficient. Then, if you still see the potential of running into an exeption error you will use try catch to handle the exception errors. How do you use try catch exception handling? You will use the following: try{ System.print(i[3]); }catch(Exception e){ System.print(“Please enter a valid integer.”); } The body in the catch allow you to perform another action if an error is found when trying to execute the body of the try. When using exception handling it allows the program to run instread of crashing when you encoounter an error. If you want to catch only a specific exception you can change the type of exception to another type. You can also have multiple catch statements on the same try. The following example shows how you can implement multiple catch exception handling with a try: int[] i = {2, 5, 6}; try{ i[3]; FileReader r = new FileReader(file); } catch( fileNotFoundException e){ “B”; } catch( ArrayIndexOutOfBounds e1){ “A”; } catch(Exception e100){ } What is finally block? Its a block that will be ran no matter the catch exptions. The following shows how this would be used. int[] i = {2, 5, 6}; try{ i[3]; FileReader r = new FileReader(file); } catch( fileNotFoundException e){ “B”; } catch( ArrayIndexOutOfBounds e1){ “A”; } finally{ } When do we use the try catch block? We use the try catch when we are not sure of how the application will interact with the environment and when there is a chance that an exception error might happen. Is throwing an exception useful? Yes, because it allows you to customize exceptions such as “Invalid EmailAddress” if you are expecting the full email address to be entered. You can throw a exception by the following: throw Exception(); Can you catch an error? No, you cannot handle errors completely but you can try to middigate them. Whats is a throws clause? Athrows clause can be used to force a class or method to be executed. It tells the compiler that we already know that there is an exception error and that the program may crash. Public void a() throws FileNotFoundException{ int[] I ={ 1, 2 , 3}; i[3]; } April 13, 2016 CSC 122 Lecture 10 What are VarArgs? VarArgs (VariableArguments ) makes it simpler to deal with arguments when their numbers are not per-determined. VarArgs are passed with the Type... Can you have multiple VarArgs? No, you can only have one VarArgs, which has to be the last parameter among parameters. What is a default method? Adefault method enables you to add new functionality to the interfaces of your libraries and ensure binary compatibility with code written for older versions of those interfaces. You specify that a method definition in an interface is a default method with the default keyword at the beginning of the method signature. What is a static method? Astatic method is a method that is associated with the class in which it is defined rather than with any object. This makes it easier for you to organize helper methods in your libraries; you can keep static methods specific to an interface in the same interface rather than a separate class. To declare a method as static you will use the static keyword at the beginning of the method signature. After the questions we started to create the ExceptionHandler Project which contains an ExceptionHandler, InvalidEmailException, and a ExceptionPropagator class. The code for these classes is listed below. import java.util.Scanner; public class ExceptionHandler { int age; String email; /** * Method that asks for age and e-mail. If any of entered values are invalid, it keeps looping * until valid values are obtained from the user. */ public void tester() { // Loop to receive a valid age. while(true) { System.out.print("Enter your age: "); Scanner sc = new Scanner(; String userInput = sc.nextLine(); try{ age = Integer.parseInt(userInput); break; } catch(NumberFormatException e) { System.out.println("You entered an invalid numeric age."); } } // Loop to receive a valid e-mail address. while(true) { System.out.print("Enter your e-mail: "); Scanner sc = new Scanner(; String userInput = sc.nextLine(); try{ if(!userInput.contains("@") || !userInput.contains(".")) { throw new InvalidEmailException(); } else { email = userInput; break; } } catch(InvalidEmailException e) { System.out.println("You entered an invalid e-mail address."); } } System.out.println("Your age: " + age + "\nYour e-mail: " + email); } public static void main(String[] args) { ExceptionHandler e = new ExceptionHandler(); e.tester(); } } public class ExceptionPropagator { /** * Simply throws an exception. That exception is propagated using the "throws" declaration * in the method. * * @throws InvalidEmailException */ public void tester() throws InvalidEmailException { throw new InvalidEmailException(); } /** * Calls "tester()", which throws an exception. That exception either needs to get caught or * can be propagated again using "throws" declaration. * * @throws InvalidEmailException */ public void tester1() throws InvalidEmailException { tester(); } /** * Calls "tester1()", which throws an exception. Finally, in main method, it is handled using try/catch * construct. Notice how the exception originally in tester method got propagated * this method. * * @param args */ public static void main(String[] args) { ExceptionPropagator e = new ExceptionPropagator(); try { e.tester1(); } catch (InvalidEmailException e1) { System.out.println("Error Error"); } } } class InvalidEmailException extends Exception { public InvalidEmailException(String message) { super(message); } public InvalidEmailException() { super(); } } April 15, 2016 CSC 122 Lecture 11 What are two types of exceptions? 1. Checked exceptions 2. Unchecked exceptions What is final? When you use the final keyword in a method declaration you are indicating that the method cannot be overridden by subclasses. What are file handlers? File handlers handle opening, reading, and writing a file. We encountered file writing in our SimpleTextEditor program. When reading a file , you can stream or buffer a file. Stream reads only a few bits of data to be read at a time. Buffer allows a fixed size of data to be read at a time. We prefer to use buffer most of the time because it is efficient. What is the difference between parsing and scanning? Scanning is the process of piecing the individual characters into separate data values. Parsing is the process of identifying the underlying structure of a string. What is JavaDoc? JavaDoc is a tool in Java that creates documentation based on your block comments. Inside your block comments tags are used to specify things such as author, version, param, see, and deprecated. Some of these tags are used with methods only and some are used with class comments only. Normally the tags are used before the comment. The following is an example of a block comment: /** * Returns the sum of all values within the array by adding the current * value to the sum. * * @param values * * @return sum */ At this point we started a new project called ExceptionHandler1. I have included the code for this below. import; import; import; import; import; import; /** * <p>This <font color="red">class</font> <a href=" q=Demonstration">demonstrates</a> how <a href="">exceptions</a> are handled with try/catch constructs.</p> * * @author Mariah Thomas * @version 1.0 * @since 4/15/2016 */ public class ExceptionHandler1 { /** * Stores temporary buffered string. */ private String value; /** * Method to play with exceptions and file IO. * @param args This parameter is for something. */ public static void main(String[] args) { ExceptionHandler1 exceptionHandler = new ExceptionHandler1(); File f = new File("/Users/MDX/Documents/Eclipse/ExceptionHandler1/src/readtext.txt"); File fWrite = new File("/Users/MDX/Documents/Eclipse/ExceptionHandler1/src/writetext.txt"); try (FileReader fileStream = new FileReader(f)) { BufferedReader br = new BufferedReader(fileStream); FileWriter fileWriter = new FileWriter(fWrite); while((exceptionHandler.value = br.readLine()) != null) { fileWriter.write(exceptionHandler.value + "\n"); } fileWriter.close(); } catch(FileNotFoundException e) { System.out.println("File is not there."); } catch(IOException e1) { System.out.println("Error reading or writing."); } } }


Buy Material

Are you sure you want to buy this material for

50 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Amaris Trozzo George Washington University

"I made $350 in just two days after posting my first study guide."

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.