问题
单项选择题
在下列源代码文件Test.java中,哪个选项是正确的类定义
A.public class test
public int x=0;
public test(int x )
this.x=x;
B.public class Test
public int x=0;
public Test(int x )
this.x=x;
C.public class Test extends T1 T2
public int x=0;
public Test(int x)
this.x=x;
D)protected class Test extends T2
public int x=0;
public Test(int x)
this.x=x;
答案
参考答案:B
解析:解析:类声明格式为[修饰符]class类名[extends父类名][implements类实现的接口列表],选项A)中源文件名与程序名不相同,Java不支持多重继承所以选项C)错误,选项D)中类的访问权限不对应为public。