well...not totally. You can't do it at compile time, but you can do it on the fly. You can add bytes to a class on the fly. If you know the Java Virtual machine spec, you can do it, but i think you might also be able to do it with Apache's BCEL:
http://jakarta.apache.org/bcel/index.html Not exactly the same as what you're thinking of in C++, but pretty close. There are also other options. Make your class abstract, and don't implement that method. make an interface. But, yeah, you could create the byte-code for a method and tie it to a class at runtime.