Can constructor be abstract method

Can constructor be abstract method

Answer : No. Constructor always need body and you cannot end it with semicolon. Please have example below:

package com.javahonk.constructorchain;

public class Toyota extends Car {

	Toyota() {
		super();
	}

	@Override
	void Car() {
		// TODO Auto-generated method stub

	}

}

abstract class Car {

	// Warning: This method has a constructor name
	abstract void Car();

	// Construct requires body and you can not end it with semicolon
	Car() {
	}

}

 

Leave a Reply

Your email address will not be published. Required fields are marked *