└── createconstructor.java /createconstructor.java: -------------------------------------------------------------------------------- 1 | class Student{ 2 | private int roll; 3 | private String name; 4 | private String dept; 5 | Student(int roll,String name,String dept) 6 | { 7 | this.roll=roll; 8 | this.name=name; 9 | this.dept=dept; 10 | } 11 | String display() 12 | { 13 | return roll+" "+name+" "+dept; 14 | } 15 | } 16 | public class Const{ 17 | public static void main(String[]args){ 18 | Student s1 = new Student(1,"kim","cse"); 19 | Student s2 = new Student(2,"jinim","aiml"); 20 | 21 | System.out.println(s1.display()); 22 | System.out.println(s2.display()); 23 | } 24 | } 25 | --------------------------------------------------------------------------------