Menu
Topics Index
...
`

Test Student Marks - Java Example Program


Test Student Marks
class TestStudentMarks
{
    public static void main(String arg[])
    {
        Student madhavan = new Student("Madhavan");
        
        madhavan.subject1 = 87;
        madhavan.subject2 = 65;
        madhavan.subject3 = 93;
        
        madhavan.total_marks = 235;
        
        System.out.println("Subject 1 = " + madhavan.subject1);
        System.out.println("Subject 2 = " + madhavan.subject2);
        System.out.println("Subject 3 = " + madhavan.subject3);
        System.out.println("Total = " + madhavan.total_marks);    
    }
}

class Student
{
    String name;

    Student(String name)
    {
        this.name = name;
    }

    int subject1;
    int subject2;
    int subject3;
    int total_marks;
}
OUTPUT

Subject 1 = 87
Subject 2 = 65
Subject 3 = 93
Total = 235

DESCRIPTION

Here we have created a Student class and with member variables subject1, subject2, subject3 and the total_marks. The marks of various subjects and the total is initialized and then they are printed.

© meritcampus 2019

All Rights Reserved.

Open In App