diff --git a/faisal.txt b/faisal.txt new file mode 100644 index 00000000..fd922bdf --- /dev/null +++ b/faisal.txt @@ -0,0 +1,22 @@ +//Java Program to demonstrate the use of static variable +class Student{ + int rollno;//instance variable + String name; + static String college ="ITS";//static variable + //constructor + Student(int r,String n){ + rollno = r; + name = n; + } + //method to display the values + void display (){System.out.println(rollno+" "+name+" "+college);} +} +//Test class to show the values of static variable +public class TestStaticVariable1{ + public static void main(String args[]){ + Student s1 = new Student(111,"Karan"); + Student s2 = new Student(222,"Aryan"); + s1.display(); + s2.display(); + } +}