在如下源代码文件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、 public class Test extends T1{
         public int x=0;
         public Test(int x){
         this.x = x;
        }
      } 
 E、protected class Test extends T2{
        public int x=0;
        public Test(int x){
            this.x=x;
        }
    }
答: 

解决方案 »

  1.   

    答案:B 肯定是对的。
          D,E 没有说得很清楚,因为没有给出T1,T2的定义。
    如果是单选就选B。没错
          多选就选B,D,E。
         
    分析:
         1> 源代码文件为Test.java。那么公共类肯定是public class Test这样的形式,所以A 是错的。
         2> JAVA中是单继承。
            C中 public class Test extends T1, T2 明显是错的。
      

  2.   

    正确答案: A、B、DJAVA中的类不允许多重继承,因而C是错误的;类不能使用protected修饰符,因而E也是错误的。A和B只是类名的命名上不同,而类名首字母大写只是一种编码风格,并不是规范,A和B都是正确的。
      

  3.   

    BD对的A首字母应该要大写
    Cjava里类是单继承的  可以继承多个接口但是用impelements关键字
    Eprotected类不能继承