假设student类定义了Name,ClassInfor,StuNumber,利用对象初始化器student类的一个对象并初始化它的属性,下面写法正确的是()
A: students2=newstudent{ClassInfor=”IT201801”,Name=”ZhangSan”,StuNumber=”10000001”};
B: students3=newstudent{StuNumber=”10000001”};
C: students1=newstudent{Name=”ZhangSan”,ClassInfor=”IT201801”,StuNumber=”10000001”};
D: 以上写法均正确
A: students2=newstudent{ClassInfor=”IT201801”,Name=”ZhangSan”,StuNumber=”10000001”};
B: students3=newstudent{StuNumber=”10000001”};
C: students1=newstudent{Name=”ZhangSan”,ClassInfor=”IT201801”,StuNumber=”10000001”};
D: 以上写法均正确
举一反三
- 假设student类定义了Name,ClassInfor,StuNumber,利用对象初始化器student类的一个对象并初始化它的属性,下面写法正确的是() A: student s1 =new student{Name=”ZhangSan”, ClassInfor =”IT201801”, StuNumber =”10000001”}; B: student s2 =new student{ ClassInfor =”IT201801”, Name=”ZhangSan”, StuNumber =”10000001”}; C: student s3 =new student{StuNumber =”10000001”}; D: 以上写法均正确
- 假设student类定义了Name,ClassInfor,StuNumber三个属性,利用对象初始化器来初始化student类的一个对象,下面写法正确的是( ) A: student s1 =new student{Name=”ZhangSan”, ClassInfor =”IT201801”, StuNumber =”10000001”}; B: student s2 =new student{ ClassInfor =”IT201801”, Name=”ZhangSan”, StuNumber =”10000001”}; C: student s3 =new student{StuNumber =”10000001”}; D: 其它三种写法均正确
- 假设student类定义了Name,ClassInfor,StuNumber,利用对象初始化器student类的一个对象并初始化它的属性,下面写法正确的是( )
- 类Student定义如下面代码所示,哪条语句可以创建类Student的对象?() A: Students=newstudent(); B: Students=Student(); C: Students=newStudent(); D: Students=null;
- 以下选项中哪个是Student类创建对象的正确语句?() A: Students1=newStudent(); B: s1=newStudent(); C: s1=Student(); D: Students1=Student();