类Teacher:classTeacher{Stringname;floatsalary;Teacher(Stringname){this.name=name;}Teacher(Stringname,floatsalary){this.name=name;this.salary=salary;}}执行语句Teachert=newTeacher(Tom”,2000.0f);后,字段salary的值是哪一项?()A.2000.0fB.0.0fC.null;D.2000

题目

类Teacher:classTeacher{Stringname;floatsalary;Teacher(Stringname){this.name=name;}Teacher(Stringname,floatsalary){this.name=name;this.salary=salary;}}执行语句Teachert=newTeacher(Tom”,2000.0f);后,字段salary的值是哪一项?()

A.2000.0f

B.0.0f

C.null;

D.2000


相似考题
更多“类Teacher:classTeacher{Stringname;floatsalary;Teacher(Stringname){this.name=name;}Teacher( ”相关问题
  • 第1题:

    publicclassPerson{privatename;publicPerson(Stringname){this.name=name;}publicinthashCode(){return420;}}Whichistrue?()

    A.ThetimetofindthevaluefromHashMapwithaPersonkeydependsonthesizeofthemap.

    B.DeletingaPersonkeyfromaHashMapwilldeleteallmapentriesforallkeysoftypePerson.

    C.InsertingasecondPersonobjectintoaHashSetwillcausethefirstPersonobjecttoberemovedasaduplicate.

    D.ThetimetodeterminewhetheraPersonobjectiscontainedinaHashSetisconstantanddoesNOTdependonthesizeofthemap.


    参考答案:A

  • 第2题:

    以下字符串定义错误的是___________。

    A.char s[7]="Teacher";

    B.char s[]="Teacher";

    C.char s[10]={"Teacher"};

    D.char s[10]="Teacher";


    char c[]={’\062’};

  • 第3题:

    下面对象的声明正确的是()。

    A.Teacher t1;

    B.Teacher t2=class Teacher();

    C.Teacher t3=new Teacher();

    D.Teacher t4=Teacher();


    Teacher t1;;Teacher t3=new Teacher();

  • 第4题:

    Person p = new Person(“张三”,23);这条语句会调用下列哪个构造方法给属性进行初始化()

    A.public Person(){}

    B.public Person(String name,int age) { this.name = name; this.age = age; }

    C.public Person(int age,String name) { this.age = age; this.name = name; }

    D.public Person(String name) { this.name = name; }


    答案:B
    解析:创建对象时会找到匹配的构造方法给属性进行初始化,由于Person p = new Person(“张三”,23);这条语句中有两个参数,而且第1个参数是String类型的,第2个参数是int类型的,因此会调用B选项中的构造方法。

  • 第5题:

    3、下面对象的声明正确的是()。

    A.Teacher t1;

    B.Teacher t2=class Teacher();

    C.Teacher t3=new Teacher();

    D.Teacher t4=Teacher();


    Teacher t1;;Teacher t3=new Teacher();