Computer Science, asked by adilmuhammed127, 5 months ago

Write a class specifier (along with constructor) that creates a class student
having two data members rollno and age.​

Answers

Answered by Anonymous
0

.java

class student

{

int rollno, age;

student (int x, int y) //defining constructor

{

rollno=x;

age=y;

}

class data

{

public static void main (String args [])

{

student s1= new student(29,18) //calling constructor

System.out.println ("Data of student : " +s1);

}

}

//constructor enables object to initialize itself

//no return type

// has same name as class

Similar questions