更多“已知stu是Student类对象,则执行“print(stu)”时会自动执行Student类的()方法。”相关问题
  • 第1题:

    设有关系模式:student(sno, sname, age, dept),现利用命令: CREATE VIEW stu AS SELECT *FROM student WHERE dept="cs"WITH CHECK OPTION 创建了一个视图。则以下SQl命令中能正确执行的是

    A.UPDATE stu SET dept="maths"

    B.UPDATE stu SET dept="maths"WHERE age>=20

    C.INSERT INTO stu VALUES ("2004001", "John", 30, "cs")

    D.INSERT INTO stu VALUES ("2004001", "John", 50, "maths")


    正确答案:C

  • 第2题:

    已知stu1和stu2是Student类的两个对象,则执行“stu1>stu2”时会自动执行Student类的()方法。

    A.__lt__

    B.__le__

    C.__gt__

    D.__ge__


    正确答案:C

  • 第3题:

    有如下语句: 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。

  • 第4题:

    如何获取参数为Object对象的具体属性

    如 Student类有属性 id , name  并且已经赋值  1,小明

    我需要定义一个共有的方法,

    public void aa(Object obj){

       ......

    }

    public static void main(String[] args){

           Student stu = new Student();

            stu.setId("1");

            stu.setName("小明");

           aa(stu);

    }

    我如何在aa方法里面获取对象具体的属性值,即:id=1  name=“小明”


     

    建议使用比较通用的办法:

     

    Student类里面重写toString() 方法

    class Student{

     public String toString(){

      return "id=" + id + " name = " + name;

     }

    }

    public void aa(Object obj){

      String stuInfo = obj.toString(); 

    }

     


    获取参数为Object对象的具体属性,通用方法:

     

    Student类里面重写toString() 方法

    class Student{

     public String toString(){

      return "id=" + id + " name = " + name;

     }

    }

    public void aa(Object obj){

      String stuInfo = obj.toString(); 

    }

  • 第5题:

    有以下说明和定义语句:struct student{int age; char num[8] ;};struct student stu [3] = { { 20, "200401" } , {21, "200402" } , {19, "200403" } };stract student * p = stu;以下选项中引用结构体变量成员的表达错误的是( )。

    A.(p++) ->num

    B.p- >num

    C.( *p).num

    D.stu[3].age


    正确答案:D
    解析:结构体变量的引用有三种形式:结构体变量.成员名;(*p).成员名;P->,成员名。所以选项A),B),C)都是正确的。

  • 第6题:

    有下列语句:  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

  • 第7题:

    下述代码执行后,有几个引用变量和几个对象?() 对象声明Student stu(对象)= new Student(“Mike”);  对象定义(开辟空间)   Student stua;(声明变量)   Stua = stu;  

    • A、 2个引用变量,1个对象
    • B、 1个引用变量,1个对象
    • C、 2个引用变量,2个对象
    • D、 1个引用变量,2个对象

    正确答案:A

  • 第8题:

    现有学生住处表Student_info,其中包括姓名(stu_name),学号(stu_id),成绩(stu_grade)。我们需要查询成绩为80分的学生姓名,要求结果按照学号降序排列。下面查询语句正确的是()。

    • A、SELECT stu_name FROM student_info Where stu_grade=80 ORDER BY stu_id ASC;
    • B、SELECT stu_name FROM student_info WHERE stu_grade=80 ORDER BY stu_id DESC;
    • C、SELECT stu_id,stu_name FROM student_info WHERE stu_grade=80 ORDER BY stu_name ASC;
    • D、SELECT stu_name FROM student_info WHERE stu_grade LIKE 80 ORDER BY stu_id DESC;

    正确答案:B

  • 第9题:

    类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

  • 第10题:

    单选题
    类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
    解析: 暂无解析

  • 第11题:

    单选题
    下述代码执行后,有几个引用变量和几个对象?() 对象声明Student stu(对象)= new Student(“Mike”);  对象定义(开辟空间)   Student stua;(声明变量)   Stua = stu;
    A

     2个引用变量,1个对象

    B

     1个引用变量,1个对象

    C

     2个引用变量,2个对象

    D

     1个引用变量,2个对象


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

  • 第12题:

    单选题
    下述代码执行后,有几个引用变量和几个对象?()   Student stu = new Student(“Mike”);  Student stua;  Stua = stu;
    A

     2个引用变量,1个对象

    B

     1个引用变量,1个对象

    C

     2个引用变量,2个对象

    D

     1个引用变量,2个对象


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

  • 第13题:

    若有以下定义的语句 struct student {int age; int num;}; struct student stu[3]={{1001,20},{1002,19},{1003,21}}; main() {stmct student *p; p=stu; …} 则以下不正确的引用是

    A.(p++)->num

    B.p++

    C.(*p).num

    D.P=&stu.age.


    正确答案:D

  • 第14题:

    类Student的声明如下:packagecom.schoolclassStudent{Stringname;intage;Student(Stringname,intage){//code}voidstudy(Stringsubject){//code}}正确调用方法study(Stringsubject)的是哪项?()

    A.Studentstu=newStudent(“Tom”,23);stu.study(“数学”);

    B.Student.study(“数学”);

    C.Studentstu=newStudent(“Tom”,23);stu.study();

    D.Studentstu=newStudent(“Tom”,23);Stringresult=stu.study(“数学”);


    参考答案:A

  • 第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题:

    有以下说明和定义语句struct student{ int age; char num[8];};struct student stu[3]={{20,"200401"},{21,"200402"},{10\9,"200403"}};struct student *p=stu;以下选项中引用结构体变量成员的表达式错误的是A.(p++)->num B.p->num C.(*p).num D.stu[3].age


    正确答案:D
    引用形式有以下三种:①结构体变量.成员名;②(*p).成员名;③p→成员名。所以A、B、C答案都是正确的。故本题答案为D。

  • 第17题:

    设有关系模式:student(sno,sname,age,dept),现利用命令: CREATE VIEW stu AS SELECT * FROM student WHERE dept="cs"WITH CHECK OPTION创建了一个视图。则以下SQL命令中能正确执行的是( )。

    A.UPDATE stu SET dept="maths"

    B.UPDATE stu SET dept="maths"WHERE age>=20

    C.INSERT INTO stu VALUES("2004001","John",30,"CS")

    D.INSERT INTO stu VALUES("200400l","John",50,"maths")


    正确答案:C

  • 第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题:

    有以下说明语句:struct Student{int num;double score;};Student stu[3]={{1001,80},{1002,75},{1003,91}},*p=stu;则下面引用形式错误的是()

    • A、p->num
    • B、(p++).num
    • C、(p++)->num
    • D、(*p).num

    正确答案:B

  • 第20题:

    下述代码执行后,有几个引用变量和几个对象?()   Student stu = new Student(“Mike”);  Student stua;  Stua = stu;  

    • A、 2个引用变量,1个对象
    • B、 1个引用变量,1个对象
    • C、 2个引用变量,2个对象
    • D、 1个引用变量,2个对象

    正确答案:A

  • 第21题:

    类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

  • 第22题:

    单选题
    有以下说明语句:struct Student{int num;double score;};Student stu[3]={{1001,80},{1002,75},{1003,91}},*p=stu;则下面引用形式错误的是()
    A

    p->num

    B

    (p++).num

    C

    (p++)->num

    D

    *p).num


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

  • 第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(“数学”);


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