The program shows basic functionality of java class and object.

Program Code:
class Student
{
private String name, city;
private int age;
public void getData(String x, String y, int t)
{
name=x;
city=y;
age=t;
}
public void printData()
{
System.out.println(“Student name = “+name);
System.out.println(“Student city = “+city);
System.out.println(“Student age = “+age);
}
}
class Cs
{
public static void main(String args[])
{
Student s1=new Student();
Student s2=new Student();
s2.getData(“Kapil”,”Delhi”,23);
s2.printData();
s1.getData(“Amit”,”Dehradun”,22);
s1.printData();
}
}
class Point
private float x,y;
public void getPoint(float a,float b)
{
x=a;
y=b;
}
public void print()
{
System.out.println("("+x+","+y+")");
}
public void abc() 
{
x=2*x;
y=3*y;
}
public static Point pqr(Point a)
Point t;
t=new Point();
t.getPoint(2*a.x,2*a.y);
return t;
}
public void ghi(Point a)
x=2*a.x;
y=3*a.y; 
}
public float getx()
return x; 
}
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: