Menu
Question Index
...

What will be the output of the following program?

public class Student {
    int rollno;
    String name;
    static String college = "RITA";
    static void chage() {
        college = "SRIT";
    }
    Student(int r, String n) {
        rollno = r;
        name = n;
    }
    void display() {
        System.out.println(rollno + " " + name + " " + college);
    }
    public static void main(String arts[]) {
        Student.chage();
        Student s1 = new Student(516, "Kiran");
        Student s2 = new Student(560, "Vishwanath");
        Student s3 = new Student(517, "Kranthi");
        s1.display();
        s3.display();
        s2.display();
    }
}


516 Kiran SRIT
516 Kiran SRIT
516 Kiran SRIT
516 Kiran SRIT
517 Kranthi SRIT
560 Vishwanath SRIT
516 Kiran RITA
516 Kiran RITA
516 Kiran RITA
516 Kiran RITA
517 Kranthi RITA
560 Vishwanath RITA
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static Keyword In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App