Get Website Learn Coding Tech Story

Java Programming Examples

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

Learn more about Polymorphism