How many classes can be defined in a single program? Explanation: Any number of classes can be defined inside a program, provided that their names are different . In java, if public class is present then it must have the same name as that of file. 10.