You extend classes in the class header. For example, a class that would extend JFrame might look something like this:
Code:
package helloworld;
import javax.swing.*;
public class MySecondApp extends JFrame {
public MySecondApp(){
}
public static void main(String[] args) {
new MySecondApp();
}
}
MySecondApp is a sub-class or child of the super-class/parent JFrame. It has the same ability of its parent, with the ability to add on (extend) the parents functionality with more methods. I've never attempted to extend classes within the same class file, but your second example does look OK.