Professional Documents
Culture Documents
A1 1
A1 1
TY CE 1 Batch : A
Assignment 1.1
Aim: Write a program to demonstrate use of static keyword: static variable
class S
{
int rollno;
String name;
static String n ="asd";
S(int r, String n)
{
rollno = r;
name = n;
}
void display()
{
System.out.println("Roll no:" +rollno+" "+"\nName: "+name+"\nCollege:
"+n);
}
}
class Aoneone
{
public static void main(String args[])
{
System.out.println("\n");
S s1 = new S(25,"qwe");
S s2 = new S(26,"zxc");
s1.display();
s2.display();
}
}
Output: