source file name: simpleoo1.java
class simpleoo1
{
int a,b;
void get(int m, int n)
{
a=m;
b=n;
}
void show()
{
System.out.println(" a: "+a+" b: "+b);
}
public static void main(String dbj[])
{
System.out.println("object oriented program: ");
simpleoo1 ob1=new simpleoo1();
simpleoo1 ob2=new simpleoo1();
ob1.get(100,200);
ob2.get(-15, -37);
ob1.show();
ob2.show();
}
}
output:
D:\JavaPrograms>javac simpleoo1.java
D:\JavaPrograms>java simpleoo1
object oriented program:
a: 100 b: 200
a: -15 b: -37
0 Comments
Post a Comment