下面哪一条语句不正确:
A: enum Gender{female, male};
B: struct Person{ char name[20]; Gender sex;
C: Person father;
D: };Person members[30];
A: enum Gender{female, male};
B: struct Person{ char name[20]; Gender sex;
C: Person father;
D: };Person members[30];
举一反三
- import java.io.*; class Person{ public void print(){System.out.print("Person ");} public void printMyGender(String s){ this.print(); System.out.print(s+" "); } } class Gender{ String type="gender"; public void print(Person p){p.printMyGender(type);} } class Female extends Gender{ public Female(){ type="female"; } } class Male extends Gender{ public Male(){ type="male"; } } class Employee extends Person{ public void print(){ System.out.print("Employee ");} } class Manager extends Employee{ public void print(){ System.out.print("Manager ");} } public class Test{ public static void main(String[] args){ Manager man = new Manager(); Employee em = new Employee(); Gender gender1 = new Male(); Gender gender2 = new Female(); gender1.print(man); gender2.print(em); } } 对于以上代码,其运行结果是
- 下列表达式中正确的是()。 A: struct person{<br/>int age; <br/>char<br/>name[8];<br/>char sex;<br/>}personl,person2; B: struct person{<br/>int <br/>age;<br/>char<br/>name[8]; <br/>char sex;<br/>} person<br/>personl,person2; C: struct person{<br/>int <br/>age;<br/>char<br/>name[8];<br/>char sex;<br/>};personl,person2; D: struct person{<br/>int <br/>age;<br/>chat<br/>name[8]="WangLin";<br/>char<br/>sex="M";<br/>} person1
- 设有一结构体类型变量定义如下: struct date { int year; int month; int day; }; struct worklist { char name[20]; char sex; struct date birthday; } person; 若对结构体变量person的出生年份进行赋值时,下面正确的赋值语句是
- 有如下定义: struct date { int yy,mm,dd;}; struct worklist { char name[20]; char sex; struct date birthday; } person; 对结构体变量person的出生年月进行赋值时,下面正确的赋值语句是
- 有如下定义:struct date{ int year;int month;int day;};struct worklist {char name[20];char sex;struct birthday;} person;对结构体变量person的出生月份进行赋值时,下面正确的赋值语句是______。 A: person=10; B: person.birthday=10; C: person.birthday.month=10; D: month=10;