Skip to main content

creating object invoking various methods

Define a class named College as described below: 

Data Members: 1) collegeName
2) principalName
3) place

Methods : 1) constructor.
2) display() to display the collegeName, principalName, and the place.

Test this class by creating an object and then invoking the various methods.




class collegeName{ 
public String collegeName; 
public String PrincipalName; 
public String place; 
public collegeName(){ 
public void display(){ 
System.out.println("College name is "+this.collegeName); 
System.out.println("Principal name is "+this.PrincipalName); 
System.out.println("Place is "+this.place); 
class displayName{ 
public static void main(String[] args) { 
collegeName c = new collegeName(); 
c.collegeName="Siliguri Institute of Technology"; 
c.PrincipalName="Dr. Mithun Chakraborty"; 
c.place="Siliguri"; 
c.display(); 
}


OUTPUT:

College name is Siliguri Institute of Technology
Principal name is Dr. Mithun Chakraborty
Place is Siliguri


Comments