Menu
Question Index
...

Write the content of the constructor to use some other constructors in the same class.
Note: Use 'this' keyword.



class StudentDetails
{
    public static void main(String s[])
    {
        Student raja = new Student("Raja", 445, 89.5);
        raja.print();
        
        Student madhavi = new Student("Madhavi", 651);
        madhavi.print();
        
        Student bindu = new Student("Bindu");
        bindu.print();

    }


    

}
class Student
{
    String name;
    int rollNumber;
    double percentage;

    Student(String name, int rollNumber, double percentage)
    {
    }

    Student(String name, int rollNumber)
    {
    }

    Student(String name)
    {
    }

    void print()
    {
        System.out.println("Details are : " + name + ", " + rollNumber + ", " + percentage);
    }
}

Doubts

Problems

Topic: Behavior Of Java Classes Using Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App