Menu
Question Index
...

What will be the output of the following program?

class OutPut
{
    public static void main(String arg[])
    {
        Student narayan = new Student("Narayan", 72);
        Student mahesh = new Student("Mahesh");
        Student kiran = new Student();

        System.out.println("Name = " + narayan.name + ", section = " + narayan.section + ", marks = " + narayan.marks);

        System.out.println("Name = " + mahesh.name + ", section = " + mahesh.section + ", marks = " + mahesh.marks);

        System.out.println("Name = " + kiran.name + ", section = " + kiran.section + ", marks = " + kiran.marks);

    }
}

class Student
{
    String name = "Kiran";
    int marks;
    char section;
    
    Student(String nameParam, int marksParam)
    {

    }
    
    Student(String nameParam)
    {

    }
    
    Student()
    {
    
    }
}


Name = Kiran, section = , marks = 0
Name = Kiran, section = , marks = 0
Name = Kiran, section = , marks = 0
Name = Narayan, section = , marks = 72
Name = Mahesh, section = , marks = 0
Name = Kiran, section = , marks = 0
Name = null, section = , marks = 72
Name = null, section = , marks = 0
Name = Kiran, section = , marks = 0
Name = Kiran, section = , marks = 72
Name = Kiran, section = , marks = 0
Name = Kiran, section = , marks = 0
Compilation Error

Doubts

Problems

Topic: Class With Multiple Constructors 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