IMPLEMENTATION OF CLASS & OBJECTS
College.java
import java.io.*;
public class
College
{
String name;
String dept;
int age;
String place;
public College(String name, String
dept,int age, String place)
{
this.name = name;
this.dept = dept;
this.age = age;
this.place = place;
}
public String getName()
{
return name;
}
public String getDept()
{
return dept;
}
public int getAge()
{
return age;
}
{
return place;
}
public
String display()
{
return("Name
:"+ this.getName()+".\n Dept:"+ this.getDept()+"\n Age:
"+ this.getAge()+"\nPlace:"+ this.getPlace());
}
public static void main(String[]
args)
{
System.out.println("Implementation of Class & Objects\n");
System.out.println("**************************\n");
College clg = new
College("Sujitha","BCA", 18, "Kallakurichi");
System.out.println(clg.display());
}
}
Compile
: javac College.java
Run : java College
Output :
Implementation of Class & Objects
**********************************
Name :Sujitha.
Dept:BCA
Age: 18
Place:Kallakurichi