Student类中存在String类型name属性,下列Student类的构造方法中,哪个是正确的?
A: Student(String name){}
B: Student(String name)
C: Student(name)()
D: NewStudent (String name){}
A: Student(String name){}
B: Student(String name)
C: Student(name)()
D: NewStudent (String name){}
举一反三
- 以下自定义数据类型的语句中,正确的是 A: A.Type student ID As String * 20 name As String * 10 age As Integer End student B: B.Type student ID As String * 20 name As String * 10 age As Integer End Type C: C.Type student ID As String name As String age As Integer End student D: C.Type ID As String * 20 name As String * 10 age As Integer End Type student
- 已知类名为Student,下面构造方法定义的有哪些? A: Student( ) B: Student(String name) C: void student() D: void input()
- 定义Student类的带1个参数的构造方法,参数类型为String,参数名为name,功能是为name属性赋值
- 【填空题】阅读程序写结果 public class Student { private static int sid = 0; private String name; int id; Student(String name) { this.name = name; id = sid++; } public void info() { System.out.println("My name is "+name+" No."+id); } public static void infoSta() { System.out.println(sid); } public static void main(String arg[]) { Student.sid = 100; Student st1 = new Student("huahua"); st1.sid = 2000; Student st2 = new Student("meimei"); st1.info(); st2.info(); } }
- 下面程序运行的结果是 struct Student { public int age; public string name; public Student(int age, string name) { this.age = age; this.name = name; } } class Program { static void Main(string[] args) { Student stu1 = new Student(18, "小方"); Student stu2 = new Student(24, "小刚"); stu2 = stu1; stu1.age = 30; stu1.name = "小燕"; Console.WriteLine("{1},{0}",stu2.age,stu2.name); } }