对下面程序表述不正确的是:()。 public string this [int index] { get { ...}}A.这是一个只读索引器B.索引器的返回值是字符串C.索引器的参数是int类型D.该索引器的调用形式是:this[O];
对下面程序表述不正确的是:()。 public string this [int index] { get { ...}}
A.这是一个只读索引器
B.索引器的返回值是字符串
C.索引器的参数是int类型
D.该索引器的调用形式是:this[O];
参考答案和解析
编译时将产生错误
相关考题:
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】字符串在程序设计中扮演着重要角色。现需要设计字符串基类string,包含设置字 符串、返回字符串长度及内容等功能。另有一个具有编辑功能的串类edlt_string,派生于string,在其中设置一个光标,使其能支持在光标处的插入、删除操作。【程序】include <iostream.h>include <stdio.h>include <string.h>class string{int length;char *data;public:int get_length() {return length;}char *get_data() {return data;}~string() {delete data;}int set data(int in_length, char *in_data);int set_data(char *data);void print() {cout<<data<<endl;}};class edit_string: public string{int cursor;public:int get_cursor() {return cursor;}void move_cursor(int dis) {cursor=dis;}int add_data(string *new_data);void delete_data(int num);};int string::set_data(int in_length,char *in_data){length=in_length;if(!data)delete data;(1)strcpy(data,in_data);return length;}int string::set data(char *in_data){(2)if(!data)delete data;(1)strcpy(data,in_data);return length;}int edit_string::add_data(string *new_data){int n,k,m;char *cp,*pt;n=new_data->get_length();pt=new_data->get_data();cp=this->get_data();m=this->get_length();char *news=new char[n+m+1];for(int i=0; i<cursor; i++)news[i]=cp[i];k=i;for(int j=0; j<n; i++,j++)news[i]=pt[j];cursor=i;for(j=k; j<m; j++,i++)(3)news[i]='\0';(4)delete news;return cursor;}void edit string::delete_data( int num){int m;char *cp;cp=this->get_data();m=this->get_length();for(int i=cursor; i<m; i++)(5)cp[i]='\0';}
阅读下面程序public class Test3{public static void main(String args[]){int x=3,y=4,z=5;String s= " xyz " ;System.out.println(s+x+y+z);}}程序运行的结果是A)xyz12B)xyz345C)xyzxyzD)12xyz
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i,String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String[]args){ print(99,"Int first"); } }A.String:String first,int:11B.int:11,String:Int firstC.String:String first,int99D.int:99,String:Int first
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { for ( int a=0;a<10;a++) { if (a==5) break; System.out.println(A); } } }A.01234B.6789C.012346789D.5
执行下面的程序段,输出结果为______。public class Q{public static void main(String argvr)){int anar[]=new int[5];System.out.println(anar[0]);}}
以下Java应用程序执行入口main方法的声明中,正确的是( )。 A.public static void main()B.public static void main(String[] args)C.public static int main(String[] args)D.public void main(String[] args)
定义属性错误的是()。 A、public int A{ get {return "100"}}B、public int A( get;set;)C、public int A{ get;set;}D、public int A{ get;}
下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { coutprivate:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { coutA. SB.PSC.DPSD.PDS
有如下程序:includeusing namespace std;class TlestClass{int n;public:TestClass(i 有如下程序: #include<iostream> using namespace std; class TlestClass { int n; public: TestClass(int k):n(k){} int get(){return n;} int get()const{return n+1;} }; int main() { TestClass p(5); colast TestClass q(6); cout<<p.get()<<q.get(); return 0; } 执行后的输出结果是( )。A.55B.57C.75D.77
阅读下列说明、图和Java代码,将应填入(n)处的字句写在对应栏内。【说明】已知对某载客车辆(Car)进行类建模,如图7-1所示,其中类Engine表示发动机引擎,类Wheel表示车轮,类Body表示车身,类Driver表示司机,类Passenger表示乘客。【Java代码】class Body{ //此处代码省略 ); //车身类class Passenger{ //此处代码省略 )/ //乘客类class Wheel{ //此处代码省略 ); //车轮类class Driver{ //司机类public String name; //表示第几路公交车司机public Driver(String driverName){name = driverName/) //构造函数};class Engine{//引擎类public String engineNo;//引擎编号public Engine(String engineNo){this.engineNo=engineNo;)//构造函数};public class Car{//汽车类static final int(1)=7; //定义最多载客数static final int MAX WHEELS =5; //定义最多轮胎数protected Engine engine;protected Driver driver;protected Body body=new Body();protected Wheel[] wheels;protected Passenger[]passengers;public Car(Driver driver){ //构造函数(2).driver=driver;engine=new Engine("TX6536型号引擎");wheels=new Wheel[MAX WHEELS];passengers=new Passenger[MAX_PASSENGERS];for(int index=0;index<MAX_WHEELS;index++){wheels[index]=new Wheel();}for(int index=0;index<MAX_PASSENGERS;index++){passengers[index]=null;}}int getPassengerNumber(){//获取车上乘客数量//此处代码省略}void getOnPassenger(Passenger aPassenger){//乘客上车//此处代码省略}void run(){ //开车if((3)){System.out.println("司机尚未上车!");return;}//此处代码省略}public static void main(String args[]){Driver driver=new Driver("第五路公交车司机");Car car=new Car((4));for (int index = 0 ; index < MAX_PASSENGERS; index ++)car.getOnPassenger((5) Passenger());car.run();}}
有如下程序:includeusing name。pace std;class AA{int n:public:AA(int k):n(k){}in 有如下程序: #include<iostream> using name。pace std; class AA{ int n: public: AA(int k):n(k){} in get( ){return n;} int get( )const{return n+1;} }; int main( ){ AA a(5); const AA b(6); cout<<a.get( )<<b.get( ); return 0: 执行后的输出结果是A.55B.57C.75D.77
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }A.String:Stringfirst,int:11B.int:11,String:Int firstC.String:String first,int:99D.int:99,String:int first
阅读下面程序 public class Test3 { public static void main(String[] args) { int x=3,y=4,z=5; String s="xyz": System.out.println(s+x+y+z); } } 程序运行的结果是A.xyz12B.xyz345C.xyzxyzD.12xyz
下面程序执行后,baz的值应是______。 public class Test9 { public static void main(String[] args) { int index = 1; int fox[] = new int [3]; iht bar = fox [index]; int baz = bar + index; System.out.println(baz); } }A.0B.1C.2D.编译错误
有如下程序:include using namespace std;class AA {int n;public:AA(int k):n(k) {} 有如下程序:#include <iostream>using namespace std;class AA { int n;public: AA(int k):n(k) {} int get(){return n;} int get()const { return n+1; }};int main(){ AAa(5); const AA b(6); cout<<a. get()<<b. get(); return ();}执行后的输出结果是( )。A.55B.57C.75D.77
执行下面程序,显示的结果为( )。 public class Test { public static void main (String args[]) { Test t=newTest(); System.out.println (Loverload ("2","3")); } int overload (intx,int y) {return x+y;} String overload (String x,Stnng y){return x+y;} }A.2B.3C.5D.23
执行下面程序段的输出结果为( )。 public class Q { public static void main(String argv[]) { int anar[]一new int[5]; System.out.println(anar[0]); } }A.0B.1C.2D.5
main方法是Java Application程序执行的入口点,关于main方法头以下( )是合法的。A.public static void main( )B.public static void main (String[ ]args)C.public static int main (String[ ]arg)D.public void main(String arg[])
阅读下列说明、图和Java代码,填补空缺。[说明]已知对某载客车辆(Car)进行类建模,如图13-2所示,其中类Engine表示发动机引擎,类Wheel表示车轮,类Body表示车身,类Driver表示司机,类Passenger表示乘客。[Java代码]class Body{ //此处代码省略 }; //车身类class Passenger{ //此处代码省略 }; //乘客类class Wheel{ //此处代码省略 }; //车轮类class Driver{ //司机类public String name; //表示第几路公交车司机public Driver(String driverName){name=driverName; }//构造函数};class Engine{ //引擎类public String engineNo; //引擎编号public Engine(String engineNo){this.engineNo=engineNo; }//构造函数};public class Car{ //汽车类static final int (1) =7; //定义最多载客数static final int MAX_WHEELS=5; //定义最多轮胎数protected Engine engine;protected Driver driver;protected Body body=new Body( );protected Wheel[]wheels;protected Passenger[]passengers;public Car(Driver driver){ //构造函数(2) .driver=driver;engine=new Engine("TX6536型号引擎");wheels = new Wheel[MAX_WHEELS];passengers=new Passenger[MAX_PASSENGERS];for(int index=0; index<MAX_WHEELS; index++){wheels[index]=new Wheel( );}for(int index=0; index<MAX_PASSENGERS; index++){passengers[index]=null;}}int getPassengerNumber( ){ //获取车上乘客数量//此处代码省略}void getOnPassenger(Passenger aPassenger ){//乘客上车//此处代码省略}void run( ){ //开车if( (3) )(System.out.printin("司机尚未上车!"); return; }//此处代码省略}public static void main(String args[]){Driver driver=new Driver("第五路公交车司机");Car car=new Car( (4) );for(int index=0; index <MAX_PASSENGERS; index++)car.getOnPassenger( (5) Passenger( ));car.run( );}}
下面程序的结果是()。includeclass A{int a;public:A():a(1){}void showa(){cout 下面程序的结果是( )。 #include<iostream.h> class A { int a; public: A():a(1){} void showa(){cout<<a;} }; Class B { int a; public: B():a(2){} void showa(){cout<<a;} ); class C:public A,public B { int a; puA.1B.2C.3D.程序有错误
阅读下面的程序public class Test {public static void main(String[] args) {for(int x = 0 ; x A.跳出循环,无输出B.0121C.01D.0123
3下列程序段运行的结果为( )。 public class Test{ static void print(String s,int i){ System.out.pdntlnC String: "+s+",int:"+i); } static void print(iht i,String s){ System.out.prinflnCint:"+i+",gtring:"+s); } public static void main(String[] args){ print(99,"Int first"); } }A.String:String first,int: 11B.int: 11,String:Int firstC.String:String first,int:99D. int:99,Stfing:Int first
试题七(共 15 分)阅读下列说明、图和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。[说明]已知对某载客车辆(Car)进行类建模,如图 7-1所示,其中类 Engine 表示发动机引擎,类 Wheel 表示车轮,类 Body 表示车身,类 Driver 表示司机,类 Passenger 表示乘客。[Java 代码]class Body{ //此处代码省略 }; //车身类class Passenger{ //此处代码省略 }; //乘客类class Wheel{ //此处代码省略 }; //车轮类class Driver{ //司机类public String name; //表示第几路公交车司机public Driver(String driverName){name = driverName;} //构造函数};class Engine{ //引擎类public String engineNo; //引擎编号public Engine(String engineNo){ this.engineNo = engineNo; } //构造函数};public class Car{ //汽车类static final int (1) = 7; //定义最多载客数static final int MAX_WHEELS = 5; //定义最多轮胎数protected Engine engine;protected Driver driver;protected Body body = new Body();protected Wheel[] wheels;protected Passenger[] passengers;public Car(Driver driver){ //构造函数(2) .driver = driver;engine = new Engine("TX6536 型号引擎");wheels = new Wheel[MAX_WHEELS];passengers = new Passenger[MAX_PASSENGERS];for (int index = 0; index MAX_WHEELS; index++){wheels[index] = new Wheel();}for (int index = 0; index MAX_PASSENGERS; index++){passengers[index] = null;}}int getPassengerNumber(){ //获取车上乘客数量//此处代码省略}void getOnPassenger(Passenger aPassenger ){ //乘客上车//此处代码省略}void run(){ //开车if( (3) ){ System.out.println("司机尚未上车!"); return;}//此处代码省略}public static void main(String args[]){Driver driver = new Driver("第五路公交车司机");Car car = new Car( (4) );for (int index = 0 ; index MAX_PASSENGERS; index ++)car.getOnPassenger( (5) Passenger());car.run();}}
阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。[Java程序]public class MainJava {public static void main(String[] args){Lot_size small=new Lot_size();Lot_size medium=new Lot_size();small.set(5,5,5,25);medium.set(10,10,10,50);System.out.println("For a small lot of area"+small.get_area()+"\n");System.out.println("the actual crops are $"+small.get_data2()+"\n");System.out.println("and ideal crops are $"+small.get data()+"\n");System.out.println("For a medium lot of area"+medium.get_area()+“\n”);System.out.println("the actual crops are $"+medium.get_data2()+"\n");System.out.println ("and ideal crops are $"+medium.get_data()+"\n");}}class Crop_assessment{private int actual_crop;private int ideal_crop;public void set(int in_actual,int in ideal){actual_crop=in_actual;ideal_crop=in_ideal;}public int get_actual_crop(){return (1) ;}public int get_ideal_crop()(return (2) ;}}class Lot_size{private int length;private int width;private Crop_assessment crop= (3) ;public void set(int 1,int W,int a,int i){length=1;width=W;crop.set(a,i);}public int get_area(){return length*width;}public int get_data()freturn (4) ;}public int get_data2()(return (5) ;}}
下面关于Java应用程序中main方法的写法,合法的是()。A、public static void main()B、public static void main(Stringargs[])C、public static int main(String[]arg)D、public void main(Stringarg[])
作为Java应用程序入口的main方法,其声明格式可以是()。A、public static void main(String[] args)B、public static int main(String[] args)C、public void main(String[] args)D、public int main(String[] args)
main方法是Java程序执行的入口点,关于main方法的方法头以下哪项是合法的()?A、public static void main( )B、public static void main( String args[] )C、public static int main(String [] arg )D、public void main(String arg[] )
单选题下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。public class FindKeyWords{ public static void main(String[]args) { String text = An array is a data structur that stores a collection of +values of the same type. You access each individual value +through an integer index. For example,if a is an array +of inergers,then a[i] is the ith integer in the array.; int arrayCount=0; int index=-1; String arrayStr=array; index=text.indexOf(arrayCount); while(index ______ 0) { ++arrayCount; index+=arrayStr.length(); index=text.indexOf(arrayStr,index); System.out.println(the text contains+arrayCount+arrays); } }}AB=C=D=