Help the world stop coronavirus! Stay home!

Prev Next

Java / Enum

Can enum have abstract methods in Java?

Yes. enum can have abstract methods. Every enum constant provide a different implementation abstract methods.

public enum Job {

	JOB1(50) {

		@Override
		void whoAmI() {
			System.out.println("I am a Software Tester.");

		}

	},
	JOB2(55) {

		@Override
		void whoAmI() {
			System.out.println("I am a Business Analyst.");

		}

	},
	JOB3(60) {

		@Override
		void whoAmI() {
			System.out.println("I am a Developer.");

		}

	};

	int payPerHour;

	Job(int payPerHour) {
		this.payPerHour = payPerHour;
	}

	abstract void whoAmI();

}

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

Arrays

Comments & Discussions