To expand on stevekeiretsu's answer, "abstract" needs a subject, and with your current wording, the only one available is the interrogative pronoun "what". That leaves "to" without an object.
And you're a bit ambiguous whether you're abstracting the number of apples or the apples themselves. The former can be handled just with the existing object type of ...
Grammatically speaking - the verb needs a subject.
What Java object type would you abstract the number of apples to?
Alternatively you can put it in the passive voice:
What Java object type would the number of apples be abstracted to?
On more of a technical level, I probably wouldn't use abstract for assigning a simple count of the number of objects, ...