Animals have been classified into being AUTOTROPHIC OR HETEROTROPHIC based on their nutrition while they are also classified as VERTEBRATE OR INVERTEBRATES based on their skeleton. A heterotrophic animal is one which depends on other organisms to obtain energy or food while an invertebrate is an animal that lacks a vertebrae column or backbone.
In this case, caterpillars are said to feed on many leaves before it makes a cocoon and becomes a butterfly. This means it relies on plants (leaves) for food, hence, it is HETEROTROPHIC. Also, it has an exoskeleton i.e. skeleton present outside the body. This means that it does not possess any bone inside to form the backbone, and hence it is an INVERTEBRATE.