Skip to content

Commit

Permalink
try catch demo: set variable value in student class
Browse files Browse the repository at this point in the history
  • Loading branch information
NirmalSilwal committed Sep 2, 2020
1 parent 7360002 commit fbc549a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CodingBlocks Training/Day15 Reference/studentClient2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package OOPS;

public class studentClient2 {

public static void main(String[] args) {

System.out.println("hello... executing");
student2 s1 = new student2();

try {
s1.setAge(-10);
System.out.println("after set statement");
} catch (Exception e) {
System.out.println("in catch block: can't set age negative");
}

System.out.println("bye bye!");
}

}

/*
* output: hello... executing
* in catch block: can't set age negative
* bye bye!
*/

0 comments on commit fbc549a

Please sign in to comment.