单选题类Student代码如下:  class Student{    String name;  int age;  Student(String nm){  name = nm; } }  执行语句Student stu = new Student()后,字段age的值是哪项?()A0BnullCfalseD编译错误

题目
单选题
类Student代码如下:  class Student{    String name;  int age;  Student(String nm){  name = nm; } }  执行语句Student stu = new Student()后,字段age的值是哪项?()
A

 0

B

 null

C

 false

D

 编译错误


相似考题

1.阅读以下说明和java代码,将应填入(n)处的字句写在对应栏内。[说明]有若干教师,每个教师只有姓名,一个教师可以指导多名研究生;每名研究生有姓名和研究方向,程序最后输出每个教师指导的所有研究生的姓名和研究方向。[Java程序]public class Teacher {String name;int top=0;Student[] student=new Student[20];public Teacher() {}public Teacher(String name) { this.name=name;}boolean add(Student stu){int len=this.student.length;if (top<len-1) {this.student[top]=siu;(1);return true;}elsereturn (2);}void disp(){System.out.println(“指导老师"”+this.name);System.out.println(“研究生:”);for(int i=0;i<(3);i++){System.out.println(“姓名:”+this.student[i].name+“\t研究方向:”+this.student[i]. search);}}public static void main(String[] args){Teacher t[]={new Teacher(“李明”),new Teacher(“王华”)};Student s1 = new Student(“孙强”,“数据库”);Student s2 = new Student(“陈文”,“软件工程”);Student s3 = new Student(“章锐”,“计算机网络”);if(! t[0].add(s1)) {System.out.println(“每个老师最多只能指导20个学生!”);}if(! t[0].add(a2)) {System.out.println(“每个老师最多只能指导20个学生!”);}if(! t[1].add(s3)) {System.out.println(“每个老师最多只能指导20个学生!”);}for(int i=0;i<2;i++)(4);}}class (5) {String name;String search;public Student(){}public Student(String name,String search){this.name=name;this.search=search;}String getName(){return this.name;}String getSearch(){return this.search;}}

参考答案和解析
正确答案: B
解析: 暂无解析
更多“单选题类Student代码如下:  class Student{    String name;  int age;  Student(String nm){  name = nm; } }  执行语句Student stu = new Student()后,字段age的值是哪项?()A  0B  nullC  falseD  编译错误”相关问题
  • 第1题:

    类Student代码如下:classStudent{Stringname;intage;Student(Stringnm){name=nm;}}执行语句Studentstu=newStudent()后,字段age的值是哪项?()

    A.0

    B.null

    C.false

    D.编译错误


    参考答案:D

  • 第2题:

    设有如下的记录类型: Type Student Number As String Name As String Age As Integer End Sub 则能正确引用该记录类型变量的代码是( )。

    A.Student.name=""

    B.Dim s As Students.name=“张红”

    C.Dims As Tye Students.name=“张红”

    D.DimsAsTypes.name=“张红”


    正确答案:B

  • 第3题:

    阅读下列XML文档,回答问题1至问题4,将解答填入对应栏内。

    【XML文档】

    <? Xml version= "1.0" encoding=" GB2312 "?>

    <!—以下是文档的主体部分→

    <college>

    <title>希赛教育</title>

    <head>软考培训部</Head>

    <Stu_Num unit="人">2</Stu_Num>

    <Student>

    <Name>张网管</Name>

    <Age>21 </Age>

    <Sex>男</Sex>

    <Class>软考2班</Class>

    </Student>

    <Student>

    <Name>李软设</Name>

    <Age>20</Age>

    <Sex>女</Sex>

    <Class>软考3班</Class>

    </Student>

    </College>

    与HTML相比,XML具有哪些特点?


    正确答案:与HTML相比XML主要有以下特点。 (1)XML是元标记语言。 (2)XML描述的是结构和语义。 (3)XML文档的显示使用特有的技术来支持。
    与HTML相比,XML主要有以下特点。 (1)XML是元标记语言。 (2)XML描述的是结构和语义。 (3)XML文档的显示使用特有的技术来支持。

  • 第4题:

    阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。

    [说明] 编写一个学生类Student,要求:

    (1) 学生类Student 属性有:

    id: long 型,代表学号

    name: String类对象,代表姓名

    age: int 型,代表年龄

    sex: boolen 型,代表性别(其中:true 表示男,false 表示女)

    phone: String 类对象,代表联系电话

    (2) 学生类Student 的方法有:

    Student (long i,String n,int a,boolean s,String p)

    :有参构造函数,形参表中的参数分别初始化学号、姓名、

    年龄、性别和联系电话。

    int getAge ():获取年龄作为方法的返回值。

    boolean getSex ():获取性别作为方法的返回值。

    String getPhone ():获取联系电话作为方法的返回值。

    public String to String ():以姓名:性别:学号:联系电话的形式作为方法的返

    import java. applet. Applet;

    import java. awt.* ;

    public class Student extends Applet {

    long id;

    String name, phone;

    int age;

    boolean sex;

    Student(long i, String n, int a, boolean s, String p)

    {

    id=i;

    name = n;

    age = a;

    sex= s;

    phone = p;

    {

    public void paint( Graphics g)

    {

    Student x= new Student (5000," xiaoliu" , 89, true, " 8989898" );

    (1);

    (2)

    g. drawstring( x. getPhone( ), 140,140);

    }

    int getAge( )

    { return age; }

    boolean getsex ( )

    { return sex; }

    String getPhone( )

    { return phone; }

    String ToString( )

    {

    (3)

    }

    }


    正确答案:g. drawString(x. ToString( ) 20100) g. drawString(x getAge( ) 80120); retum(“姓名”+name + “学号:” + id + “联系电话:”" +phone) ;
    g. drawString(x. ToString( ) ,20,100) g. drawString(x, getAge( ) ,80,120); retum(“姓名”+name + “学号:” + id + “联系电话:”" +phone) ;

  • 第5题:

    以下scanf函数调用语句中对结构体变量成员的不正确引用的是()。  struct node{      char name[20];      int age;      int sex; }student[5],*p;  p=student; 

    • A、scanf(“%s”,student[0].name);
    • B、scanf(“%d”,&student[0].age);
    • C、scanf(“%d”,&(p->sex));
    • D、scanf(“%d”,p->age);

    正确答案:D

  • 第6题:

    执行以下代码后,下面哪些描述是正确的() public  class  Student{  private String name = “Jema”;  public void setName(String name){  this.name = name;  }  public String getName(){  return this.name;  }  public static void main(String[] args){  Student s;  System.out.println(s.getName()); } }

    • A、输出null
    • B、第10行编译报错
    • C、第11行编译报错
    • D、输出Jema

    正确答案:C

  • 第7题:

    类Student的声明如下:   package com.school class Student{ String name;  int age;  Student(String name,int age){  //code } void study(String subject){ / /code } }  正确调用方法study(String subject)的是哪项?() 

    • A、Student stu = new Student(“Tom”,23); stu.study(“数学”);
    • B、Student.study(“数学”);
    • C、Student stu = new Student(“Tom”,23); stu.study();
    • D、Student stu = new Student(“Tom”,23); String result=stu.study(“数学”);

    正确答案:A

  • 第8题:

    对于如下代码,描述正确的是哪项?()  class Student{   public static void main(String[] args){   Student student=new Student();  }  }  

    • A、new Student()创建了Student对象的一个实例
    • B、Student student声明了对象Student的一个引用
    • C、class Student声明了一个类
    • D、new Student()创建了一个类
    • E、Student student 声明了一个类

    正确答案:A,B,C

  • 第9题:

    类Student代码如下:D   class Student{   String name;   int age;   Student(String nm){ (构造方法)   name = nm;  }  }   执行语句Student stu = new Student()后,字段age的值是哪项?()

    • A、 0
    • B、 null
    • C、 false
    • D、 编译错误

    正确答案:D

  • 第10题:

    单选题
    以下scanf函数调用语句中对结构体变量成员的不正确引用的是()。  struct node{      char name[20];      int age;      int sex; }student[5],*p;  p=student;
    A

    scanf(“%s”,student[0].name);

    B

    scanf(“%d”,&student[0].age);

    C

    scanf(“%d”,&(p->sex));

    D

    scanf(“%d”,p->age);


    正确答案: D
    解析: 暂无解析

  • 第11题:

    单选题
    类 Student 中字段mark的缺省值是哪项?()   Class Student{   String name;   int age;   float market;   ·········   }
    A

    0.0f

    B

    numll

    C

    false

    D

    0

    E

    0.0


    正确答案: B
    解析: 暂无解析

  • 第12题:

    单选题
    有下列语句:  struct Birthday{public int year;  public int month;   public int day;}; struct Student{ int no;  string name;   int age;  public Birthday bir; };  ……  Student Stu;  如果要把Stu的出生年份赋值为1988,正确的语句是()
    A

     Stu.bir.year=1988;

    B

     Stu.year=1988;

    C

     Stu. Birthday.year=1988;

    D

     Student. Birthday.year=1988;


    正确答案: D
    解析: 暂无解析

  • 第13题:

    设有如下的记录类型: TypeStudent number As String name AS String age As Integer End Type 则正确引用该记录类型变量的代码是( )。

    A.Student.name="张红"

    B.Dim s As Student s.name="张红"

    C.Dim s As Type Student s.name="张红"

    D.Dim s As Type s.name="张红"


    正确答案:B

  • 第14题:

    有如下语句: Type Student Name As String Age As Integer Sex As String End Type Dim Stu As Student With Stu .Name="张红" .Age=22 .Sex="女" End With 执行Print Stu.Age语句后的结果是

    A.张红

    B.22

    C.“女”

    D.Age


    正确答案:B
    解析:本题重点需理解自定义类型Student以及Student类型的变量Stu的使用。在使用Stu变量时用到了With...End With的结构,在该结构中的语句.Age=22相当于语句Stu. Age=22。故最后执行Print Stu. Age语句的结果值应为22。

  • 第15题:

    有如下用户定义类型及操作语句: Tyoe Student SNo As String Sname As String SAge As Integer End Type Dim Stu As Student With Stu SNo=”200609001” SName=”陈果果“ A ge=19 End With 执行MsgBox Stu,Age 后,消息框输出结果是 【13】


    正确答案:
    19

  • 第16题:

    设有如下的记录类型: Type Student number As String name As String age As Integer End Type 则正确引用该记录类型变量的代码是______。

    A.StUdent.name=""

    B.Dim s As StUdent s.name="张红"

    C.Dim s As Type Student s.name="张红"

    D.Dim s As Type s.name="张红"


    正确答案:B

  • 第17题:

    有下列语句:  struct Birthday{public int year;  public int month;   public int day;}; struct Student{ int no;  string name;   int age;  public Birthday bir; };  ……  Student Stu;  如果要把Stu的出生年份赋值为1988,正确的语句是()

    • A、 Stu.bir.year=1988;
    • B、 Stu.year=1988;
    • C、 Stu. Birthday.year=1988;
    • D、 Student. Birthday.year=1988;

    正确答案:A

  • 第18题:

    类Student代码如下:  class Student{    String name;  int age;  Student(String nm){  name = nm; } }  执行语句Student stu = new Student()后,字段age的值是哪项?() 

    • A、 0
    • B、 null
    • C、 false
    • D、 编译错误

    正确答案:D

  • 第19题:

    类 Student 中字段mark的缺省值是哪项?()   Class Student{   String name;   int age;   float market;   ·········   }  

    • A、0.0f
    • B、numll
    • C、false
    • D、0
    • E、0.0

    正确答案:A

  • 第20题:

    对于如下代码,描述正确的是哪项? ()   class Student{   public static void main(String[] args){   Student student = new Student();  }  }  

    • A、Student student 声明了一个类
    • B、new Student()创建了Student 对象的一个实例
    • C、Student student 声明了对象Student 的一个引用
    • D、class Student 声明了一个类

    正确答案:A,B,D

  • 第21题:

    单选题
    类Student代码如下:  class Student{    String name;  int age;  Student(String nm){  name = nm; } }  执行语句Student stu = new Student()后,字段age的值是哪项?()
    A

     0

    B

     null

    C

     false

    D

     编译错误


    正确答案: D
    解析: 暂无解析

  • 第22题:

    单选题
    执行以下代码后,下面哪些描述是正确的() public  class  Student{  private String name = “Jema”;  public void setName(String name){  this.name = name;  }  public String getName(){  return this.name;  }  public static void main(String[] args){  Student s;  System.out.println(s.getName()); } }
    A

    输出null

    B

    第10行编译报错

    C

    第11行编译报错

    D

    输出Jema


    正确答案: D
    解析: 暂无解析

  • 第23题:

    单选题
    类Student代码如下:D   class Student{   String name;   int age;   Student(String nm){ (构造方法)   name = nm;  }  }   执行语句Student stu = new Student()后,字段age的值是哪项?()
    A

     0

    B

     null

    C

     false

    D

     编译错误


    正确答案: C
    解析: 暂无解析

  • 第24题:

    单选题
    类Student的声明如下:   package com.school class Student{ String name;  int age;  Student(String name,int age){  //code } void study(String subject){ / /code } }  正确调用方法study(String subject)的是哪项?()
    A

    Student stu = new Student(“Tom”,23); stu.study(“数学”);

    B

    Student.study(“数学”);

    C

    Student stu = new Student(“Tom”,23); stu.study();

    D

    Student stu = new Student(“Tom”,23); String result=stu.study(“数学”);


    正确答案: D
    解析: 暂无解析