Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by weeko ( 5 years ago )
import java.io.*;
public class Week8Task2 {
/**
* .
* @throws NullPointerException nullPointerEx.
*/
public void nullPointerEx() throws NullPointerException {
String value = null;
int i = Integer.getInteger(value);
}
/**
* .
* @return nullPointerExpression.
*/
public String nullPointerExpression(){
try {
nullPointerEx();
return "Không có lỗi";
} catch (NullPointerException ex) {
return "Lỗi Null Pointer";
}
}
/**
* .
* @throws ArithmeticException arithmeticEx.
*/
public void arithmeticEx() throws ArithmeticException {
int value = 10 / 0;
}
/**
* .
* @return arithmeticExpression.
*/
public String arithmeticExpression() {
try {
arithmeticEx();
return "Không có lỗi";
} catch (ArithmeticException ex) {
return "Lỗi Arithmetic";
}
}
/**
* .
* @throws ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsEx.
*/
public void arrayIndexOutOfBoundsEx() throws ArrayIndexOutOfBoundsException {
String[] arr = new String[2];
arr[10] = "1111";
}
/**
* .
* @return arrayIndexOutOfBoundsExpression.
*/
public String arrayIndexOutOfBoundsExpression(){
try {
arrayIndexOutOfBoundsEx();
return "Không có lỗi";
} catch (ArrayIndexOutOfBoundsException ex) {
return "Lỗi Array Index Out of Bounds";
}
}
/**
* .
* @throws FileNotFoundException fileNotFoundEx.
*/
public void fileNotFoundEx() throws FileNotFoundException {
File file = new File("abc.txt");
FileReader fileReader = new FileReader(file);
}
/**
* .
* @return fileNotFoundExpression.
*/
public String fileNotFoundExpression() {
try {
fileNotFoundEx();
return "Không có lỗi";
} catch (FileNotFoundException ex) {
return "Lỗi File Not Found";
}
}
/**
* .
* @throws IOException ioEx.
*/
public void ioEx() throws IOException {
File file = new File("abc.txt");
FileReader fileReader = new FileReader(file);
}
/**
* .
* @return ioExpression.
*/
public String ioExpression() {
try {
ioEx();
return "Không có lỗi";
} catch (IOException ex) {
return "Lỗi IO";
}
}
public static void main(String[] args) {
// Week8Task2 w = new Week8Task2();
// System.out.println(w.arrayIndexOutOfBoundsExpression());
}
}
Revise this Paste