Menu
Question Index
...

What will be the output of the following program?

class College {
    public static void main(String s[]) {
        Student mahesh = new Student();
        System.out.println("Name = " + mahesh.name);
        System.out.println("Marks = " + mahesh.marks);
        System.out.println("Section = " + mahesh.section);
        Student kiran = new Student();
        System.out.println("Name = " + kiran.name);
        System.out.println("Marks = " + kiran.marks);
        System.out.println("Section = " + kiran.section);
    }
}
class Student {
    String name = "Kiran";
    int marks = 76;
    char section = 'A';
}


Name = null
Marks = 0
Section =
Name = Kiran
Marks = 76
Section = A
Name = Kiran
Marks = 76
Section = A
Name = Kiran
Marks = 76
Section = A
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Member Variable 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