Sun Sep 19 2021

Polymorphism

File Name: polymorphism.java

import java.io.*;

class employee {
	employee(String name) {
		System.out.println("Employee Name: "+name+"\n");
	}

	employee(String name, String designation) {
		System.out.println("Employee Name: "+name);
		System.out.println("Designation: "+designation+"\n");
	}

	employee(String name, String designation, int salary) {
		System.out.println("Employee Name: "+name);
		System.out.println("Designation: "+designation);
		System.out.println("Salary: "+salary+"\n");
	}
}

class polymorphism {
	public static void main(String args[ ]) {
		employee emp = new employee("Kavin");
		employee manager = new employee("Jecob","Manager");
		employee programmer = new employee("Vicky","Programmer",10000);
	}
}




/* Output */
Employee Name: Kavin

Employee Name: Jecob
Designation: Manager

Employee Name: Vicky
Designation: Programmer
Salary: 10000
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.