一个java题目,感觉自己打出来的好像不是很符合题目要求

题目:定义类ActionListenerTest,实现ActionListener接口,实现抽象方法actionPerfomed,在方法中输出你自己的学号和姓名.

自己的代码:
package work1;

public interface ActionListener {
public abstract void actionPerfomed();
}





package work1;
import java.util.Scanner;
public class ActionListenerTest implements ActionListener {
Scanner input=new Scanner(System.in);
public void actionPerfomed(){
    System.out.println("请输入您的学号:");
    int a=input.nextInt();
    System.out.println("请输入您的姓名:");
    String b=input.next();
    System.out.println("您的学号:"+a+"您的姓名:"+b);
}
public static void main(String[] args){
    ActionListenerTest a=new ActionListenerTest();
    a.actionPerfomed();
}
}

请问是这样做吗?

看起来题目没有那么复杂,只需要输出你的个人信息就行了,这是老师布置的作业吧?
我觉得这个题目考察的只是接口的实现,方法的重写,因此个人以为这样的代码就可以了。。。

package work1;

public class ActionListenerTest implements ActionListener {

    @Override
    public void actionPerfomed(){
        System.out.println("学号:xxxxxxxx");
        System.out.println("姓名:xxxx");
    }

}

楼主写对了,直接输出的话适用性比较小。