问题 单项选择题

在下列源代码文件Test. java中,正确定义类的代码是( )。

A.pblic class test { public int x=0; public test(int {thi x=x;} }

B.public class Test { public int x=0; public Test(int {thi x=x;} }

C.public class Test extends T1,T2{ public int x = 0; public Test(int { thi x = x; }}

D.protected class Test extends T2{ public int x = 0; public Test(int {thi x = x; } }

答案

参考答案:B

解析: 本题主要考查类声明格式为[修饰符]class类名[extends父类名][implements类实现的接口列表],选项A中源文件名与程序名不相同,Java不支持多重继承所以选项C错误,选项D中类的访问权限不对,应为public。

单项选择题
单项选择题