Menu
Question Index
...

What will be the output of the following program?

public class College {
    public static void main(String[] args) {
        Student[] student = new Student[1];
        student[0].name = "Khan";
        student[0].marks = 92;
        student[0].section = 'A';
        for (Student element : student) {
            System.out.print(element.name + " ~ ");
            System.out.print(element.marks + " ~ ");
            System.out.print(element.section);
        }
    }
}
class Student {
    String name;
    int marks;
    char section;
}


null ~ 0 ~
Khan ~ 92 ~ A
Compilation Error
Runtime Error

Doubts

Problems

Topic: Creating Array Of Objects 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