Question Index

Write a program to get the list of first class students. Students with marks greater than or equal to 60 and less than 70 are considered first class.

Input (List) Output (List)
[Mahesh-80, Rajesh-25, Suresh-66, Ramesh-69] [Suresh-66, Ramesh-69]
[Mahesh-60, Rajesh-70, Suresh-63, Ramesh-35] [Mahesh-60, Suresh-63]
[Mahesh-60, Rajesh-61, Suresh-62, Ramesh-63] [Mahesh-60, Rajesh-61, Suresh-62, Ramesh-63]
[Mahesh-55, Rajesh-70] []

import java.util.ArrayList;
import java.util.List;

class FirstClassStudents
    public static void main(String s[])
        List<Student> list = new ArrayList<Student>();
        list.add(new Student("Mahesh", 80));
        list.add(new Student("Rajesh", 25));
        list.add(new Student("Suresh", 66));
        list.add(new Student("Ramesh", 69));
        List<Student> qualified = getFirstClassStudents(list);
        System.out.println("First Class students are " + qualified);


    public static List<Student> getFirstClassStudents(List<Student> allStudents) {

class Student {

    String name;
    int marks;

    public Student(String name, int marks) { = name;
        this.marks = marks;

    public String toString() {
        return name + "-" + marks;



Topic: Java ArrayList

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App