Classes for data validation - Java Quiz Question


What will be the output of the following program?

public class ClassDataValidation {
    public static void main(String arg[]) {
        Student ashok = new Student("Ashok");
        ashok.print("LINE A");
        ashok.marks = ashok.setMarks(150);
        ashok.print("LINE B");
        ashok.marks = ashok.setMarks(50);
        ashok.print("LINE C");
    }
}
class Student {
    String name = "Kiran";
    int marks = 20;
    char section = 'A';
    Student(String name) {
        this.name = name;
    }
    int setMarks(int marks) {
        if (marks >= 0 && marks <= 100) {
            this.marks = marks;
        }
        return this.marks;
    }
    void print(String line) {
        System.out.println(line + " : " + name + " - " + marks + " - " + section + ".");
    }
}


A
LINE A : Ashok - 20 - A.
LINE B : Kiran - 20 - A.
LINE C : Kiran - 50 - A.
B
LINE A : Ashok - 20 - A.
LINE B : Ashok - 0 - A.
LINE C : Ashok - 50 - A.
C
LINE A : Ashok - 20 - A.
LINE B : Ashok - 20 - A.
LINE C : Ashok - 50 - A.
D
Some other output
E
Compilation Error or Runtime Error