Problem statement:
Can we have final constructor in java class?
No ! we cannot have final constructor in java class.
Can we have final constructor in java class?
No ! we cannot have final constructor in java class.
- public class NoFinalConstructor {
- public final NoFinalConstructor() {
- System.out.println("default");
- }
- public static void main(String[] args) {
- NoFinalConstructor st = new NoFinalConstructor();
- }
- }
Output: compile time error - modifier 'final' is not allowed.
No comments:
Post a Comment