+ 1
Assign and print the roll no and name student having names"john"and "sam"respctively by creating two object of class 'student'
Class and object in program how to create this program please help me https://www.sololearn.com/discuss/2368086/?ref=app https://www.sololearn.com/discuss/2366797/?ref=app
2 Respuestas
+ 3
Can you show your attempt and you should not use other threads in your question bro
0
/* Assign anf print the roll no and name of two student name sam and john and roll no is 12 and 13 respectively by creating two object of calss student*/
public class Student
{ int roll_no;
String name;
public static void main(String[] args) { Student s1 =new Student ();
s1.name ="john ";
s1.roll_no =12;
Student s2 =new Student ();
s2.name ="Sam";
s2.roll_no =13;
System .out. println ("name of 1st student is "+s1.name +" and roll no is "+s1.roll_no );
System .out.println ("name of second student is "+s2.name + " and roll no is "+s2.roll_no );
}
}