[Demonstration 1]

[Buggy Method]
@Override
public void actionPerformed(ActionEvent e) {
    String m = maxNum.getText();
    int maxNum1 = Integer.parseInt(m);
    String q = numOfQuestions.getText();
    int questions = Integer.parseInt(q);
    String[] equations = new String[questions];
    int[] answers = new int[questions];
    for (int i = 0; i < questions; i++) {
        Random random = new Random();
        int operator = random.nextInt(4);
        String[] arr = new String[4];
        if (add.isSelected() == true) {
            arr[0] = "+";
        }
        if (sub.isSelected() == true) {
            arr[1] = "-";
        }
        if (mult.isSelected() == true) {
            arr[2] = "X";
        }
        if (div.isSelected() == true) {
            arr[3] = "/";
        }
        int firstNum = random.nextInt(maxNum1 + 1);
        int secNum = random.nextInt(maxNum1 + 1);
        while (arr[operator] == null) {
            operator = random.nextInt(4);
        }
        if (carryOver.isSelected() == false) {
            char firstDig = String.valueOf(Math.abs((long) firstNum)).charAt(0);
            char secondDig = String.valueOf(Math.abs((long) secNum)).charAt(0);
            if (firstDig + secondDig >= 10) {
                firstDig /= 2;
                secondDig /= 2;
            }
        }
        String equation = (firstNum + " " + arr[operator] + " " + secNum + " :");
        equations[i] = equation;
        System.out.println(equation);
        System.out.print("\n");
        if (operator == 0) {
            answers[i] = firstNum + secNum;
        } else if (operator == 1) {
            answers[i] = firstNum - secNum;
        } else if (operator == 2) {
            answers[i] = firstNum * secNum;
        } else if (operator == 3) {
            answers[i] = firstNum / secNum;
        }
    }
    String fileName = "Equations.txt";
    String fileName1 = "Answers.txt";
    try {
        PrintWriter outputStream = new PrintWriter(fileName);
        for (int k = 0; k < equations.length; k++) {
            outputStream.println(equations[k]);
            outputStream.println("\n");
            outputStream.println("\n");
        }
        PrintWriter outputStream1 = new PrintWriter(fileName1);
        for (int l = 0; l < answers.length; l++) {
            outputStream1.println(answers[l]);
            outputStream1.println("\n");
            outputStream1.println("\n");
        }
        outputStream.close();
        outputStream1.close();
        outputStream.close();
    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}

[Buggy Hunk]
if(firstDig + secondDig >= 10){

[Patch]
if(firstDig + secondDig > 10 || firstDig + secondDig == 10){

[Demonstration 2]

[Buggy Method]
private void resetTitle() {
    switch(mScope) {
        case 1:
            getActivity().setTitle(R.string.nav_movies);
            break;
        case 2:
            getActivity().setTitle(R.string.nav_tv);
            break;
        case 3:
            getActivity().setTitle(R.string.nav_fav);
            break;
        default:
            getActivity().setTitle(R.string.nav_movies);
            Log.e(LOG_TAG, "Error resetting toolbar title");
            break;
    }
}

[Buggy Hunk]
private void resetTitle(){

[Patch]
private void resetTitle() throws  NullPointerException{

[Demonstration 3]

[Buggy Method]
public void printVehicle() {
    System.out.println(year + " " + make + " " + model);
    System.out.println("VIN: " + vin);
    System.out.println("Color: " + color);
    System.out.println("Weight: " + weight);
    System.out.println("MSRP: $" + msrp);
    System.out.println("Mileage: " + numMiles);
    System.out.println("Miles Since Last Oil Change: " + milesSinceLastOilChange);
    if (dueForOilChange) {
        System.out.println("*** NEEDS OIL CHANGE ***");
    }
    System.out.println(disclaimer);
    System.out.print("\n\n");
}

[Buggy Hunk]
System.out.println("Weight: " + weight);

[Patch]
System.out.println("Weight: " + weight + " lbs");