Skip to content

Commit 11faea7

Browse files
committed
Exceptions exercise added
1 parent 3959483 commit 11faea7

4 files changed

Lines changed: 65 additions & 0 deletions

File tree

Exceptions/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/OSGi%Minimum-1.2"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

Exceptions/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Exceptions</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.4
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
11+
org.eclipse.jdt.core.compiler.source=1.3
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
public class ExceptionHandling {
3+
4+
5+
public static void main(String[] args) {
6+
7+
//todo:
8+
//1.) Execute the following program. It will throw Exceptions.
9+
//Catch the Exceptions using their proper Names till no further
10+
//exceptions occur.
11+
//
12+
//2.) Taking the square root of a negative number won't cause
13+
//the exception. Write your own Exception for this case and
14+
//write a method which throws this exception
15+
16+
int a = 5;
17+
int b = 0;
18+
int div = a/b;
19+
20+
int[] arr = new int[5];
21+
arr[5] = 7;
22+
23+
String one = "one";
24+
int i = Integer.parseInt(one);
25+
26+
double c = -7.0;
27+
double d = Math.sqrt(c);
28+
System.out.println(d);
29+
}
30+
31+
}

0 commit comments

Comments
 (0)