If you do like your first example you'll declare a class inside the other class. I don't think it's possible to do like you first example, in Java, because you use the extends-keyword before the class is even declared and/or implemented.
The other example is possible, because you declares another class outside any others, and use the extends-keyword after the first class is declared.
In your second example the class Vowel is inherited from the class Alfabet. That means the Vowel have the same functionality as Alfabet - but you have the option to extend Vowel with more.
I'm not a Java-programmer, but C++ isn't much different (syntax), so you'll probably could understand my example;
class Base
{
public:
void specialFunction()
{
std::cout << "This is a special function!" << std::endl;
}
void anotherSpecialFunction()
{
std::cout << "This is another special function!" << std::endl;
}
};
// Java: class Derived extends Base
class Derived : public Base
{
public:
void aVerySpecialFunction()
{
std::cout << "This is a very special function!!!" << std::endl;
}
};
If making an instance of class Base you'll only get access specialFunction and anotherSpecialFunction. If you then want to use an extended version of the class, then you can use Derived, which have another special function, aVerySpecialFunction, but this class can also access the ones from Base.
Base bInst;
Derived dInst;
// This is the only two functions we can access with an instance of Base
bInst.specialFunction();
bInst.anotherSpecialFunction();
// But with an instance of Derived, we can access the same ones + one more
dInst.specialFunction();
dInst.anotherSpecialFunction();
dInst.aVerySpecialFunction(); // Another function!