You have a syntax error because you define "public int getX()..." inside the main method.
You also have a logical error because there is no instance field "x" in class Apple. In the Apple static method "main" you reference a local variable "x", but since it's a local variable, it isn't seen outside of the block (method) where it's defined. That variable "x" has nothing to do with apples or fruit.
You probably meant for class Apple does to extend class Fruit. Even that wouldn't work in this case, because you defined "x" in Fruit as a private field. That's appropriate, you don't *want* to be able to reference it in the sub-class. The proper way to implement your classes would be to define "x" and getX() in Fruit, as you've done, and implement getX() in Fruit rather than making it abstract. If you think getX() needs to be abstract, then get rid of the private x.
The problem with made-up examples like this is that they don't have meaning. What is "x"? How does it relate to fruit or apples? The whole point of OO is to model objects -- things like apples -- so it's hard to say what's the "right" way to implement a property called "x".
Again, it's hard to answer your question since we don't know what you're trying to do. But I suspect you want to define your classes like this:
If you're just playing around with Java, then here's a tip: All instance fields, like "x" should be defined as private. Avoid re-defining an instance field in sub-classes because it gets confusing. Since you defined "x" in Fruit it is also automatically part of Apple, so there's no need to redefine it. In my code, there's no way to assign a value to x. There's no single "right way" to do this -- it depends on what "x" represents. You could initialize it as you define it or in Fruit's constructor, and, if you design calls for it, you could have a "setX(int x)" method.