You are on page 1of 2

MITRAJSINH 170410107013

TY CE 1 Batch : A

Assignment 1.2
Aim: Write a program to demonstrate use of static keyword: static
function

class S
{
int rollno;
String name;
static String n ="asd";
S(int r, String n)
{
rollno = r;
name = n;
}
static void ch()
{
n = "pqr";
}
void display()
{
System.out.println("Roll no:" +rollno+" "+"\nName: "+name+"\nCollege:
"+n);
}
}
class Aonetwo
{
public static void main(String args[])
{
System.out.println("\n");
S.ch();
S s1 = new S(31,"qwe");
S s2 = new S(32,"zxc");
s1.display();
s2.display();
}
}
MITRAJSINH 170410107013
TY CE 1 Batch : A

Output:

You might also like