7 Pages

SOFT1002L05_Exceptions

Course: SOFT 1002, Fall 2009
School: Allan Hancock College
Rating:
 
 
 
 
 

Word Count: 1942

Document Preview

Lecture Today's SOFT1x02 05: Exceptions School of Information Technologies Using Exceptions Read Big Java: Ch 15, Ch 4.7, Ch 16.1 August 07 SOFT1x02 University of Sydney 2 Argh! Run-time Errors!* Exceptions Your friend when thigngs go baddly rong^Q#((Q#%_)U*((__)).. Whenever a Java program deals with the external environment, many things can go wrong un-available blah not allowed to blurgh wrong format of...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> Allan Hancock College >> SOFT 1002

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Lecture Today's SOFT1x02 05: Exceptions School of Information Technologies Using Exceptions Read Big Java: Ch 15, Ch 4.7, Ch 16.1 August 07 SOFT1x02 University of Sydney 2 Argh! Run-time Errors!* Exceptions Your friend when thigngs go baddly rong^Q#((Q#%_)U*((__)).. Whenever a Java program deals with the external environment, many things can go wrong un-available blah not allowed to blurgh wrong format of bleagh etc. How will the program cope? have many different return values, indicating error conditions; then have calling program test for each? there must be a cleaner way to arrange it! SOFT1x02 University of Sydney *segmentation fault. core dumped. day ruined. August 07 5 Exceptions Exceptions are a mechanism to gracefully handle run-time errors. In general, you try a piece of code and catch any exceptions generated. Using Exceptions Exception mechanism: When an error is encountered Construct an exception Object (which contains information about the error); Throw (also called "raise") the exception; This stops normal flow of control. The exception may be caught somewhere and dealt with; otherwise the execution stops. August 07 SOFT1x02 University of Sydney 6 August 07 SOFT1x02 University of Sydney 7 1 How to throw an exception ... if (aWeight < 0.0) { // expecting non-negative throw new IllegalArgumentException("negative weight for "+this.mName); /*this location can never be reached */ } /* code here for the normal case */ When to throw an exception? You might throw an exception when: an error or a situation occurs that makes the normal flow of processing unsuitable; `someone else' should handle the error. Exceptions are especially useful if the same type of error occurs in several locations in a program. When code catches an exception, the error can be dealt with, and execution may continue, or it can clean up the damage and exit. August 07 SOFT1x02 University of Sydney 8 August 07 SOFT1x02 University of Sydney 9 What exception? There are a variety of Exception subclasses already in the library. You can also declare your own subclass class AnimalNotHungryException extends Exception { public AnimalNotHungryException(String detail) { super(detail); } } It is good practice to declare a constructor taking a message August 07 SOFT1x02 University of Sydney Exception handling in Java Separate the normal case code ("try") from the code for weird situations ("catch") Have several different catch clauses, depending on kind of exception The optional finally block is always executed at the end of the catch region. After try clause completes successfully, or after a catch block is executed. try { // do something // which could throw // Exceptions } catch(EOFException e) { // do something to deal with // the situation } catch(FileNotFoundException e) { // do something else } catch (Exception e) { // do something very general } finally { // code that should happen // after normal/weird case } 10 August 07 SOFT1x02 University of Sydney 11 Exception catching Example try { double r1 = quadraticRoots(a, b, c); } catch(ArithmeticException e) { System.out.println("Oops: " + e.toString()) } PSST! Pass it on... If an exception occurs in a method constructed and thrown explicitly or raised by some other method that is called, Possible output: You can refer to e in the catch clause > Oops: quadratic equation has no real roots And if it cannot be handled within the method (i.e., if there is no catch block for it associated with a try block containing the place where the exception occurred), Then that method will terminate and throw the same exception to the caller of the method. The exception will be passed up until someone can handle it. 12 August 07 SOFT1x02 University of Sydney August 07 SOFT1x02 University of Sydney 13 2 Declaring Exceptions Methods should declare the exceptions they can throw: public void read() throws IOException { read data from a file } Checked or Unchecked? Java has these two types of exceptions: All exceptions that are derived from RuntimeException are unchecked; all other subclasses of Exception are checked. This is enforced for a checked exception So caller can know what exceptions might arise, and be prepared to catch them (or throw them further). Java has checked and unchecked exceptions. August 07 SOFT1x02 University of Sydney Checked exceptions are checked by the compiler to ensure they are handled within the method or thrown further; Unchecked exceptions do not need to be declared: the compiler won't check that they are handled or passed on properly. 14 August 07 SOFT1x02 University of Sydney 15 Checked Exceptions Checked exceptions force tighter coding so they can make coding painful (unless you use an IDE that puts try/catch automatically!); "Throws" header public void getData(...) throws IOException { read data from a file } are useful especially for situations out of programmer's influence (e.g., in groups!) Unchecked exceptions are often produced by programmer errors in ordinary code, e.g., NullPointerException IndexOutOfBoundsException ClassCastException SOFT1x02 University of Sydney public void dealWithData(...) { try { /*call getData()*/ } catch (IOException e) { System.out.println("Oops: faulty datafile?"); } } August 07 16 August 07 SOFT1x02 University of Sydney 17 Exceptions principles Do not throw an exception To avoid thinking about flow control in expected situations e.g., don't deal with the end of the input this way! Heirarchy of Exceptions Here are some of the common exceptions you may use to "simplify" your code! Do not catch an exception if it is not the right place to handle it maybe let the calling routine handle it; to shut the compiler up! Use exceptions in exceptional cases. August 07 SOFT1x02 University of Sydney August 07 SOFT1x02 University of Sydney 18 19 3 Exceptions: Summary try {...} compulsory catch {...} at least one finally {...} optional Java has checked and unchecked exceptions. Checked exceptions which are not caught internally must be mentioned in method header throws clause. RuntimeException and all its subtypes are unchecked All the others are checked August 07 SOFT1x02 University of Sydney Exceptions are not suitable for expected situations flow-control! Catch and handle the exception you if can do so sensibly, else pass it on. 20 August 07 SOFT1x02 University of Sydney 21 Common errors Putting try/catch blocks with too small scope: put them around the entire piece of code you expect to work! File Input and Exceptions When files are read they are expected in a certain format: name: Bill Bloggs; age 24 name Bill Bloggs age 24 Name Bloggs, Bill Age: 24 Returning too general an Exception type: use the appropriate exception if you can Not conveying information with the exception thrown: construct it with a detailed message. August 07 SOFT1x02 University of Sydney 22 August 07 SOFT1x02 University of Sydney 23 Parsing Files have to be parsed: if they are not in the right format then they won't be understood. File reading When reading a file try to read in the data in the right form; When reading a file, incorrect formatting often uses Exceptions. e.g., NumberFormatException, IllegalArgumentException, etc. (all Runtime exceptions) catch the case(s) where it isn't; throw an exception with detailed information about what caused the error. August 07 SOFT1x02 University of Sydney 24 August 07 SOFT1x02 University of Sydney 25 4 Non-Persistence Data used by a Java program has different lifetimes next, Persistence instance variables: from object construction till the object is garbage collected (when there are no more references to it) local variables: from method entry till method return But all data is lost when the program ends including if the program crashes. Data is "transient". Operating system design reflects hardware: typical RAM technology does not keep its state when power is turned off. (You have to boot-up your machine.) August 07 SOFT1x02 University of Sydney 27 Persistence The data kept by organizations is This data must not be lost when programs end or computers crash! It is stored on devices that keep their state until overwritten disk tape CD DVD etc. essential, valuable. File System A key aspect of the operating system is to provide a file system. Divide the persistent storage into variable size chunks user-assigned names hierarchical naming, through folders/directories access control text files are easily read and written to; binary files need more tricks (translation). We will focus on text files. Files can be text or binary. August 07 SOFT1x02 University of Sydney 28 August 07 SOFT1x02 University of Sydney 29 File access from Java Construct an object instance in your program that represents the access. There are several possible classes, depending on how you will access it! e.g., FileWriter f = new FileWriter(filename); Warning: this constructor throws FileNotFoundException Writing text files Use the PrintWriter class and its methods print and println: // open file for writing: FileWriter writer = new FileWriter( filename ); // use write() to write one character at a time or.. PrintWriter out = new PrintWriter( writer ); // an alternative shortcut is // PrintWriter out = new PrintWriter(filename); out.println( "Hello World" ); // always close the file after you are done // to commit changes out.close(); Call methods of this object. The Java environment deals with the OS to operate on the file. Remember to call f.close() once you no longer need to access the file. SOFT1x02 University of Sydney August 07 30 August 07 SOFT1x02 University of Sydney 31 5 Reading from Text files The FileReader class has a method (inherited from Reader interface) int read() to read one character from the file This is too painful to use for most purposes So construct a Scanner that takes its information from the Reader Scanner has a method nextLine() to read a whole line (as a String) Scanner in = new Scanner(f); String line = in.nextLine(); Reading Primitive types When a line of a file contains "...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Allan Hancock College - SOFT - 1002
8/15/07This week's Lecture SOFT1x0207: ProfessionalismSchool of Information TechnologiesProfessionalismDefinition, Professional Societies Professional behaviour Ethical Issues for Programmers/Designers Applied Ethics in assignment Conflicting R
Allan Hancock College - SOFT - 1002
OverviewSOFT1x02 GUIs &amp; Event HandlingSchool of Information Technologies GUI concepts and history Swing classes and their use Event-handling Components and layout See Big Java chapter 10 and 12August 07SOFT1x02 University of Sydney2GUIGra
Allan Hancock College - SOFT - 1002
SOFT1002 (Sem2, 2003)SOFT1x02 15: Introduction to Data StructuresSchool of Information TechnologiesThe March of ProgressThe March of Progress 1980: C printf(&quot;%10.2f&quot;, x); 1988: C+ cout &lt; setw(10) &lt; setprecision(2) &lt; showpoint &lt; x; 1996: Java ja
Allan Hancock College - SOFT - 1002
SOFT1002 (Sem2, 2005)SOFT1002Trees and Composite Design PatternSchool of Information Technologies Due 5pm on Friday 25th May Submit code as .zip on WebCTDSP1September 07SOFT1x02 University of Sydney1September 07SOFT1x02 University o
Allan Hancock College - SOFT - 1002
SOFT1002 (Sem2, 2005)Today's Lecture SOFT1902Grammars &amp; ParsingSchool of Information Technologies GrammarsA notation to describe language syntax Derivations Parse trees Introduction to ParsingRead Ch. 20 of Kingston's Textbook1SOFT1002 Un
Allan Hancock College - SOFT - 1002
Grammar &lt;joggle&gt; := &quot;joggle&quot; { &lt;decl&gt; } &quot;run&quot; { &lt;stmt&gt; } &quot;endjoggle&quot; &lt;decl&gt; := &lt;type&gt; &lt;identifier&gt; &quot;;&quot; &lt;type&gt; := &quot;int&quot; &lt;stmt&gt; := &lt;assign&gt; | &lt;if&gt; | &lt;dowhile&gt; | &lt;print&gt; | &lt;compound&gt; &lt;assign&gt; := &lt;identifier&gt; &quot;=&quot; &lt;expr&gt; &quot;;&quot; &lt;if&gt; := &quot;if&quot; &lt;expr&gt; &quot;
Allan Hancock College - SOFT - 1002
Zoo private List mAnimals private List mStaff public Zoo() public void addAnimal(Animal anAnimal) public void removeAnimal(Animal anAnimal) public void addStaff(Keeper aKeeper) public void removeStaff(Keeper aKeeper) public void addDutyForAnimal(Keep
Allan Hancock College - SOFT - 1002
System Feed Animal Weigh Animal KeeperReportsList All the Keepers of an AnimalList All the Animals Kept by a Keeper Add/Remove/ Update Keepers Add/Remove/ Update Animals Zoo Manager Report the Total Cost of Feed for the ZooZoo Manager Reports
Cornell - P - 116
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: handout1.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o handout1.ps handout1 %
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: P661_flyer.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSSI12 CMSS9 CMSS8 CMMI7 CMSY7 %EndComments %DVIPSWebPage: (www.radicaleye.com)
Cornell - P - 661
Eective Field Theory(Physics 661)TUE &amp; THU: 2:55pm 4:25pm Rockefeller 127This course will provide an introduction to eective eld theory and the renormalization group a subject of immense importance to modern research in quantum eld theory. The c
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS1.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS1 -o PS1.ps %DVIPSParameters
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS2.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS2 -o PS2.ps %DVIPSParameters
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS3.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS3 -o PS3.ps %DVIPSParameters
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS4.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS4 -o PS4.ps %DVIPSParameters
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS5.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS5 -o PS5.ps %DVIPSParameters
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS6.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS6 -o PS6.ps %DVIPSParameters
Cornell - P - 661
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS7.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS7 -o PS7.ps %DVIPSParameters
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: handout1.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o handout1.ps handout1 %
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: ps1.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o ps.ps ps1 %DVIPSParameters:
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: ps2.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o ps.ps ps2 %DVIPSParameters:
Cornell - P - 651
) | 100y'c9g(!@T ) ) 3 A &amp; % 6 &amp; &amp; &amp; 3 &amp; % % &amp; A &amp; A 6 6 S 2a#F5 (cF | Q% | ( | B(hB8 $ cF V 9 (U g 285 % ) 3 &amp; A 6 | 0T~9e#9u(! 9T1uFQF!B!T!6T(TF! &amp; &amp; %
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: ps3.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o ps.ps ps3 %DVIPSParameters:
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: ps4.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o ps.ps ps4 %DVIPSParameters:
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: ps5.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o ps.ps ps5 %DVIPSParameters:
Cornell - P - 651
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: ps6.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMR12 CMTI10 CMSY10 CMBX10 CMMI10 CMMI7 %+ CMR7 CMSY7 CMEX10 %EndComments
Cornell - P - 651
Cornell University Department of Physics Phys 651 October 3, 2006Relativistic Quantum Field Theory, Fall 2006 Homework Assignment # 6(Due Wednesday, October 11 (or Monday, October 16), after the lecture.) Lectures and Reading Assignments: Readings
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: ps7.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMR12 CMTI10 CMSY10 CMBX10 CMMI7 CMMI10 %+ CMR7 CMEX10 %EndComments %DVIPS
Cornell - P - 651
Cornell University Department of Physics Phys 651 October 16, 2006Relativistic Quantum Field Theory, Fall 2006 Homework Assignment # 7(Due Monday, October 23, after the lecture.) Lectures and Reading Assignments: Readings are from An Introduction
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: ps8.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMR12 CMTI10 CMSY10 CMBX10 %EndComments %DVIPSWebPage: (www.radicaleye.com
Cornell - P - 651
Cornell University Department of Physics Phys 651 October 22, 2006Relativistic Quantum Field Theory, Fall 2006 Homework Assignment # 8(Due Monday, October 30, after the lecture.) Lectures and Reading Assignments: Readings are from An Introduction
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: ps9.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMR12 CMTI10 CMSY10 CMBX10 CMMI10 CMR7 %+ CMSY7 CMMI7 CMEX10 %EndComments
Cornell - P - 651
Cornell University Department of Physics Phys 651 October 31, 2006Relativistic Quantum Field Theory, Fall 2006 Homework Assignment # 9(Due Monday, November 6, after the lecture.) Lectures and Reading Assignments: Readings are from An Introduction
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: ps10.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMR12 CMTI10 CMSY10 CMBX10 CMMI10 CMMI7 %+ CMSY7 %EndComments %DVIPSWebPa
Cornell - P - 651
Cornell University Department of Physics Phys 651 November 5, 2006Relativistic Quantum Field Theory, Fall 2006 Homework Assignment # 10(Due Wednesday, November 15, after the lecture.) Lectures and Reading Assignments: Readings are from An Introduc
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: ps11.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMR12 CMTI10 CMSY10 CMBX10 CMR7 CMEX10 %+ CMMI10 CMMI7 CMSY7 %EndComments
Cornell - P - 651
Cornell University Department of Physics Phys 651 November 15, 2006Relativistic Quantum Field Theory, Fall 2006 Homework Assignment # 11(Due Wednesday, November 22, after the lecture.) Lectures and Reading Assignments: Readings are from An Introdu
Cornell - P - 651
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: ps12.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMR12 CMTI10 CMSY10 CMBX10 CMMI10 CMR7 %EndComments %DVIPSWebPage: (www.r
Cornell - P - 651
Cornell University Department of Physics Phys 651 November 22, 2006Relativistic Quantum Field Theory, Fall 2006 Homework Assignment # 12(Due Wednesday, November 29, after the lecture.) Lectures and Reading Assignments: Readings are from An Introdu
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Organization.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMBX12 CMR12 CMTT12 CMTI12 %EndComments %DVIPSWebPage: (www.radi
Cornell - P - 443
Physics 443M. Neubert, S.J. LeeCourse OrganizationSpring 2006Lectures and Section Lectures are 9:059:55 am on Monday, Wednesday and Friday in 110 Rockefeller. Section meetings are 3:354:25 pm on Friday in 231 Rockefeller. The instructor of the
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: qmintro.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips qmintro -o qmintro.ps %DVI
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: PS1.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMMI12 CMEX10 CMR8 CMSY10 CMMI8 %+ CMSY8 CMR6 CMTI12 %EndComments %
Cornell - P - 443
Physics 443 Problem Set 1M. Neubert, S.J. Lee(due February 1)Spring 20061. The relation between frequency and wave length in a cavity is () = c2 2 - 0,0 = const.Using that = 2 and k = 2/, find the dispersion relation (k). What are the
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: PS2.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMMI12 CMEX10 CMSY10 CMMI8 CMR8 %+ CMSY8 CMTI12 %EndComments %DVIPS
Cornell - P - 443
Physics 443 Problem Set 2M. Neubert, S.J. Lee(due February 8)Spring 20061. Solve the time-independent Schrdinger equation for a centered infinite square well o with an attractive -function potential in the center: V (x) = -c (x) ; if -a &lt; x &lt;
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: PS3.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMMI12 CMSY10 CMEX10 CMMI8 CMSY8 %+ CMR8 CMTI12 %EndComments %DVIPS
Cornell - P - 443
Physics 443 Problem Set 3M. Neubert, S.J. Lee(due February 15)Spring 20061. Find expressions for the operators p and x in the momentum representation. For ^ ^ an arbitrary state in Hilbert space, evaluate the brackets p|^| and |^| in x x term
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: PS4.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMTI12 CMSY10 CMMI12 CMMI8 CMR8 %+ CMSY8 CMMIB10 CMEX10 CMR7 CMR10
Cornell - P - 443
Physics 443 Problem Set 4M. Neubert, S.J. Lee(due February 22)Spring 20061. a) For the one-dimensional harmonic oscillator, show that a coherent state of the form | N exp(^+ )|0 awith arbitrary complex (and N a normalization factor) is an
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Prelim1.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMMI12 CMSY10 CMR8 CMEX10 CMMI8 %+ CMMIB10 CMBX12 CMSY8 %EndCom
Cornell - P - 443
Physics 443 Preliminary Exam 1M. Neubert, S.J. Lee(February 23)Spring 20061. Write down the time-dependent Schrdinger equation for a free particle in the o momentum representation, where the wave function is (p, t) = p|(t) . Solve this equatio
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Prelim1_Solutions.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMMI12 CMSY10 CMR8 CMBX12 CMEX10 %+ CMSY8 CMMI8 CMR6
Cornell - P - 443
Physics 443 Preliminary Exam 1 SolutionsM. Neubert, S.J. Lee(February 23)Spring 20061. Write down the time-dependent Schrdinger equation for a free particle in the o momentum representation, where the wave function is (p, t) = p|(t) . Solve t
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: PS5.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMMI12 CMSY10 CMMI8 CMSY8 CMR8 %+ CMEX10 CMR6 CMMIB10 CMTI12 CMSY6
Cornell - P - 443
Physics 443 Problem Set 5M. Neubert, S.J. Lee(due March 1)Spring 20061. The eigenfunctions of the hydrogen atom corresponding to maximal angular momentum (l = n - 1) are n,n-1,m (r, , ) = 1 (2n)! 2 na3 22r nan-1m e-r/na Yn-1 (, ) ,whe
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: PS6.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips PS6 -o PS6.ps %DVIPSParameters
Cornell - P - 443
4 F 8 @ 4 8 @ 8 4 @ 8 YHG2YEBs zYD92FACBs%A92 k g 6 4 2 kj j lj j g g `cWjnh ) w753mnn`hmsfm}m`8ryl0 $&amp; ' 1v( $&amp; % s $&amp; % ) &quot;# P ( &quot;# &quot;# 0! s ' j i k j g ns}8h}hmAm u o j i i j j j i i
Cornell - P - 443
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: PS7.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMSS17 CMSS12 CMR12 CMR8 CMMIB10 CMSY10 CMEX10 CMMI12 %+ CMMI8 CMSY8 CMTI12 %EndComment
Cornell - P - 443
Physics 443 Problem Set 7M. Neubert, S.J. Lee(due March 15)Spring 20061 1. For a particle with spin 2 , construct the matrix n S representing the component of spin along a direction n parameterized in terms of spherical coordinates,sin cos