Skip to content

sir, only one code of exception handling is shown to my account, please let my account see the other codes alos #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added CCVT_Code_Distribute/Lecture Files/Lecture 1.pdf
Binary file not shown.
Binary file added CCVT_Code_Distribute/Lecture Files/Lecture 2.pdf
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file added CCVT_Code_Distribute/Lecture Files/Lecture3.pdf
Binary file not shown.
Binary file added CCVT_Code_Distribute/Lecture Files/Lecture4.pdf
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions CCVT_Code_Distribute/Lecture Files/References
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Most of the data taken from Oracle Java Docs, For further Reading visit : https://docs.oracle.com/javase/tutorial/
22 changes: 22 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.rt.exceptionexamples;

public class Employee {


int id;
String name;
public Employee(int id, String name) {
super();
this.id = id;
this.name = name;
}

@Override
public String toString() {
// TODO Auto-generated method stub
return "Employee Id"+id+" Employee Name:"+name;
}



}
39 changes: 39 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception10.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.rt.exceptionexamples;

class Exception10 {
// Through an exception out of the method.
static void procA() {
try {
System.out.println("inside procA");
throw new RuntimeException("demo");
} finally {
System.out.println("procA's finally");
}
}
// Return from within a try block.
static void procB() {
try {
System.out.println("inside procB");
return ;
} finally {
System.out.println("procB's finally");
}
}
static void procC() {
try {
System.out.println("inside procC");
System.exit(0);
} finally {
System.out.println("procC's finally");
}
}
public static void main(String args[]) {
try {
procA();
} catch (Exception e) {
System.out.println("Exception caught");
}
procB();
procC();
}
}
24 changes: 24 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception11.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.rt.exceptionexamples;

class MyException extends RuntimeException {
private int detail;
MyException(int a) {
detail = a;
}
public String toString() {
return "MyException[" + detail + "]should be less than 10";
}
}
class Exception11 {
static void compute(int a) {
System.out.println("Called compute(" + a + ")");
if(a > 10)
throw new MyException(a);
System.out.println("Normal exit");
}
public static void main(String args[]) {

compute(1);
compute(20);
}
}
29 changes: 29 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.rt.exceptionexamples;

class Exception2 {
public static void main(String args[]) {
int d, a;

try { // monitor a block of code.
d = 1;
a = 42 / d;
int a1[]=new int[10];
a1[11]=21;
System.out.println("This will not be printed.");
//throw new IllegalAccessException();
} catch (ArithmeticException e) { // catch divide-by-zero error
System.out.println("Division by zero.");
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Array error");
}

catch(Exception o)
{
System.out.println("Super Exception");
}

System.out.println("After catch statement.");
}
}
20 changes: 20 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.rt.exceptionexamples;

class Exception3 {
public static void main(String args[]) {
try {
int a = args.length;
System.out.println("a = " + a);
int b = 42 / a;
int c[] = { 1 };
c[42] = 99;
} catch(ArithmeticException e) {
//System.out.println("Divide by 0: " + e.toStri);
e.printStackTrace();

} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Array index oob: " + e);
}
System.out.println("After try/catch blocks.");
}
}
16 changes: 16 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.rt.exceptionexamples;

class Exception4 {
public static void main(String args[]) {
try {
int a = 0;
int b = 42 / a;
} catch(ArithmeticException e) { // ERROR - unreachable
System.out.println("This is never reached.");
}
catch(Exception e) {
System.out.println("Generic Exception catch.");
}

}
}
21 changes: 21 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception5.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.rt.exceptionexamples;

class Exception5 {
public static void main(String args[]) {
try {
int a = args.length;

int b = 42 / a;
System.out.println("a = " + a);

if(a==1) a = a/(a-a);
if(a==2) {
int c[] = { 1 };
c[42] = 99;
}
} catch(Exception e) {
System.out.println("Array index Out-of-bounds: " + e);

}
}
}
25 changes: 25 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception6.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.rt.exceptionexamples;

class Exception6 {
static void nesttry(int a) {
try {
if(a==1) a = a/(a-a);
if(a==2) {
int c[] = { 1 };
c[42] = 99;
}
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Array index out-of-bounds: " + e);
}
}
public static void main(String args[]) {
try {
int a = 2;
int b = 42 / a;
System.out.println("a = " + a);
nesttry(a);
} catch(ArithmeticException e) {
System.out.println("Divide by 0: " + e);
}
}
}
16 changes: 16 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception7.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.rt.exceptionexamples;

import java.io.IOException;

class Exception7 {
static void demoproc() throws IOException {
throw new IOException();//("demo");

}

public static void main(String args[]) throws IOException {

demoproc();

}
}
17 changes: 17 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception8.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.rt.exceptionexamples;

class Exception8 {
static void throwOne() throws IllegalAccessException {
System.out.println("Inside throwOne.");
throw new IllegalAccessException("demo");
//throw new ArithmeticException();
}
public static void main(String args[]) {
try {
throwOne();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
System.out.println("Got it"+e.getMessage());
}
}
}
17 changes: 17 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception9.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.rt.exceptionexamples;

class Exception9 {
static void throwOne() {
System.out.println("Inside throwOne.");
try {
throw new IllegalAccessException("demo");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String args[]) {

throwOne();

}}
16 changes: 16 additions & 0 deletions CCVT_Code_Distribute/src/com/rt/exceptionexamples/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.rt.exceptionexamples;

public class Test {

public static void main(String[] args) {
// TODO Auto-generated method stub

Employee e1=new Employee(1, "Ram");
System.out.println(e1.toString());

// System.out.println(e1.getClass());
// System.out.println(e1.hashCode());

}

}
Loading