Wednesday, April 2, 2014

Java program of student using "this" keyword

package mypackages.student;

import java.io.*;

public class Student implements Serializable
{
private int rn=0;
private String name="";
private String dnm="";
private String loc="";

public Student()
{

}
public Student(int rn,String name)
{
this.name=name;
this.rn=rn;
}
public void setRn(int rn)
{
this.rn = rn;
}
public void setDnm(String dnm)
{
this.dnm = dnm;
}
public void setName(String name)
{
this.name = name;
}
public int getRn()
{
return rn;
}
public String getDnm()
{
return dnm;
}
public String getName()
{
return name;
}
public String getLoc()
{
return loc;
}
public void setLoc(String loc)
{
this.loc = loc;
}
public String toString()
{
String str = "";
str += "\nRoll No : " +this.rn ;
str += "\nName    : " +this.name;
return str;
}
}

No comments:

Post a Comment