class StudentClass{
int rollno;
String name;
static String subject = "Java Programming Language";
static void change(){
subject = "C programming Language";
}
StudentClass(int r, String n){
rollno = r;
name = n;
}
void display (){
System.out.println(rollno+" "+name+" "+subject);
}
public static void main(String args[]){
StudentClass.change();
StudentClass s1 = new StudentClass (1,"Rahim");
StudentClass s2 = new StudentClass (2,"Ram");
StudentClass s3 = new StudentClass (3,"Rocky");
s1.display();
s2.display();
s3.display();
}
}
1 Rahim C programming Language
2 Ram C programming Language
3 Rocky C programming Language
Press any key to continue . . .
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.