Want to write articles/new answer to be published in javapedia.net? Send in your article with your name to javatutorials2016@gmail.com!

Prev Next

Java / final keyword

Can a static method be final in Java?

Yes, you can make a static method final in Java.

When we declare a static method as final its prevents from method hiding and encounters compile time error: Cannot override the final method from Parent.

public class Parent {

	final static void helloWorld() {

		System.out.println("Hello from Parent.");
	}

}

class Child extends Parent {

	// compile error : Cannot override the final method from Parent
	static void helloWorld() {

		System.out.println("Hello from child.");
	}

}

❤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...

static keyword

Comments & Discussions