网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
若有定义String tom=""boy"";String hill=""boy"";则表达式(tom==hill)的值为()
- A、True
- B、False
- C、1
- D、0
参考答案
更多 “若有定义String tom=""boy"";String hill=""boy"";则表达式(tom==hill)的值为()A、TrueB、FalseC、1D、0” 相关考题
考题
本题中定义了一个带有参数的构造方法javal,并定义了一个该类的对象temp。构造方法javal有两个参数:字符串name和整型age。定义对象temp时将字符串“Tom"和整数17传递给构造方法,构造方法将这两个参数打印输出。 public class javal{ String name; int age; public static void main(String[]args){ String name="Tom"; int age=17; javal temp = ; } public javal(String name, ){ ; this.age= age; System.out.println(name+"is"+age+" years old."); } }
考题
定义一个长度为5值为空的字符串数组,下列选项不正确的是A.String a[]={"","","","",""};B.String a[5];C.String [5]a;D.String[]a=new String[5]; for(int i=0;i<5;a[i++]=null);
考题
下面main()方法的定义哪些是正确的()。A.publicstaticvoidmain(Stringargs[]){}B.publicstaticvoidmain(String[]){}C.publicstaticvoidmain(String[]args){}D.publicstaticvoidmain(String[]x){}
考题
定义—个长度为5值为空的字符串数组,下列选项不正确的是A.String a[]={"","","","","",""};B.String a[5];C.String[5]a;D.String[] a new String[5]; for(int i=0;i<5;a[i++]-null);
考题
定义一个表示10个值为null的字符串数组,下面选项正确的是( )。A.String []a;B.String a[];C.char a[l0][];D.String a[]=new String[10];
考题
定义一个表示10个值为null的字符串数组,下面选项正确的是A.String [] a;B.String a[];C.char a[10][];D.String a[]=new String[10];
考题
下列程序的执行结果是 public class Testff{ public static void main(String args[]){ String sl=new String("I am boy"); String s2=new String("I am boy"); System.out.println(sl==s2); } }A.真B.假C.I am boyD.都不正确
考题
已知String类定义如下:class String{public:String(const char *str = NULL); // 通用构造函数String(const String another); // 拷贝构造函数~ String(); // 析构函数String perater =(const String rhs); // 赋值函数private:char *m_data; // 用于保存字符串};尝试写出类的成员函数实现。
考题
定义一个表示100个值为null的字符串数组,正确的选项是______。A.String[ ]a;B.String a[ ];C.char a[100][ ];D.String a[ ]=new String[100]
考题
下列程序的执行结果是 public class Testhh { public static void main(String args [] ) { Strings1=new String("I am boy"); Strings2=new String("I am boy"); System.out.println(s1.equals(s2)); } }A.真B.假C.I am boyD.都不正确
考题
阅读下列说明和C++代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 以下C++代码实现一个简单的聊天室系统(ChatRoomSystem),多个用户(User)可以向聊天室(ChatRoom)发送消息,聊天室将消息展示给所有用户。类图如图6-1所表示。图6-1 类图【C++代码】 includeiostream include string using namespace std; class User { private: string name; public: User(string name){ (1) =name; } ~User(){} void setName(string name) { this-name=name; } string getName(){ return name; } void sendMessage(string message); }; class ChatRoom { . public: static void showMessage(User* user, string message) { cout[user-getName()] : messageendl; } }; void User::sendMessage(string message) { (2) (this,message); } class ChatRoomSystem{ public: . . void startup() { User* zhang = new User(John); User* li = new User(Leo); zhang-sendMessage(Hi! Leo!); li_sendMessage(Hi! John!); } void join(User* user) { (3) (HeIIo Everyone! l am+user-getName()); } . }; int main(){ ChatRoomSystem*crs= (4) ; crs-startup(); crs-join( (5) (Wayne)); delete crs; } /* 程序运行结果: [John]:Hi! Leo! [Leo]:Hi! John! [Wayne]:Hello Everyone! I am Wayne /*
考题
若输入 "I am a boy!",下列程序的运行结果为______。 char connect(string1,string2,string) char string1[],string2[],string[]; { int i,j; for (i=0;stringl[i] !='\0';i++) string[i]=stringl[i]; for (j=0;string2[j] !='\0';j++) string[i+j]=string2[j]; string[i+j ] ='\0'; } main ( ) { char s1 [100] , s2 [100] , s [100]; printf ("\n 输入 string1: \n"); scanf("%s",s1); printf (" \n 输入 string2: \n" ); scanf ("%s", s2); connect (s1, s2, s); printf ("%s\n", s); }A.I am a boy!B.输入string2:C.I amD.I am a boy!
考题
试题六(共 15 分)阅读下列说明和 C++代码,填补代码中的空缺,将解答填入答题纸的对应栏内。【说明】以下 C++代码实现一个简单的聊天室系统(ChatRoomSystem),多个用户 (User)可以向聊天室(ChatRoom)发送消息,聊天室将消息展示给所有用户。 类图如图 6-1 所表示。
【C++代码】#include#include using namespace std; class User {private:string name; public:User(string name){ (1) =name;}~User(){}
void setName(string name) {this->name=name; } string getName(){return name;}void sendMessage(string message); }; class ChatRoom { . public:static void showMessage(User* user, string message) { coutgetName()"] : " zhang->sendMessage("Hi! Leo!");li_>sendMessage("Hi! John!"); }void join(User* user) { (3) ("HeIIoEveryone!l am"+user->getName()); . ;} . };int main(){ChatRoomSystem*crs= (4) ; crs->startup();crs->join( (5) ("Wayne")); delete crs; }/* 程序运行结果: [John]:Hi! Leol [Leo]:Hi! John![Wayne】:Hello Everyone!Iam Wayne/*
考题
类Teacher: class Teacher{ String name; float salary; Teacher(String name){ this.name = name; } Teacher(String name,float salary){ this.name = name; this.salary = salary; } } 执行语句Teacher t = new Teacher(“Tom”,2000.0f);后,字段salary的值是哪一项?() A、 2000.0fB、 0.0fC、 null;D、 2000
考题
class Guy { String greet() { return "hi "; } } class Cowboy extends Guy { String greet() { return "howdy "; } } class Wrangler extends Cowboy { String greet() { return "ouch! "; } } class Greetings2 { public static void main(String [] args) { Guy g = new Wrangler(); Guy g2 = new Cowboy(); Wrangler w2 = new Wrangler(); System.out.print(g.greet()+g2.greet()+w2.greet()); } } 结果是什么?() A、hi hi ouch!B、hi howdy ouch!C、ouch! howdy ouch!D、编译失败
考题
class Guy{String greet(){return “hi“}} class Cowboy extends Guy {String greet(){return“howdy”}} class Surfer extends Guy {String greet(){return“dudel”}} class Greetings{ public static void main (string[]args){ Guy[] guy= {new Guy(),new Cowboy(),new Surfer()}; for(Guy 0: guys) System.out.print(g.green()); } } 结果为: A、运行时异常被输出B、第7行出现一个错误,编译失败C、第8行出现一个错误,编译失败D、hi hi hiE、hi hawdy doude
考题
下面哪个是对字符串String的正确定义()。A、String s1=null;B、String s2=’null’;C、String s3=(String)‘abc’;D、String s4=(String)‘/uface’;
考题
C#中,新建一字符串变量str,并将字符串"Tom’sLivingRoom"保存到串中,则应该使用下列哪条语句()。A、string str="Tom/’s Living Room";B、string str="Tom’s Living Room";C、string str("Tom’s Living Room");D、string str("Tom"s Living Room");
考题
类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(“数学”);
考题
You work as the application developer at Hi-Tech.com. You create a new custom dictionary named MyDictionary. Choose the code segment which will ensure that MyDictionary is type safe?()A、 Class MyDictionary Implements Dictionary (Of String,String)B、 Class MyDictionary Inherits HashTableC、 Class MyDictionary Implements IDictionaryD、 Class MyDictionary End Class Dim t as New Dictionary (Of String, String) Dim dict As MyDIctionary= CType (t,MyDictionary)
考题
单选题You work as the application developer at Hi-Tech.com. You create a new custom dictionary named MyDictionary. Choose the code segment which will ensure that MyDictionary is type safe?()A
Class MyDictionary Implements Dictionary (Of String,String)B
Class MyDictionary Inherits HashTableC
Class MyDictionary Implements IDictionaryD
Class MyDictionary End Class Dim t as New Dictionary (Of String, String) Dim dict As MyDIctionary= CType (t,MyDictionary)
考题
单选题在VB语言中,下列定义变量语句格式正确的是()。A
Dim As String xuehaoB
Dim xuehao As StringC
Dim String As xuehaoD
Const xuehao As String
考题
单选题现有: class Guy { String greet() { return "hi"; } } class Cowboy extends Guy { String greet() { return. "howdy";}} class Wrangler extends Cowboy { String greet() { return "orch!"; } } class Greetings2 { public static void main (String [] args) { Guy g=new Wrangler(); Guy g2=new Cowboy(); Wrangler w2=new Wrangler(); System. out .print (g.greet()+g2.greet()+w2 .greet()); } } 结果是什么?()A
hi hi ouch!B
ouch! howdy ouch!C
hi howdy ouch!D
编译失败E
运行的咐候有异常抛出
考题
单选题现有: class Guy {String greet() {return "hi"; } } class Cowboy extends Guy ( String greet() ( return "howdy ¨; ) ) class Surfer extends Guy (String greet() (return "dude! ";)) class Greetings { public static void main (String [] args) { Guy [] guys = ( new Guy(), new Cowboy(), new Surfer() ); for (Guy g: guys) System.out.print (g.greet()}; } } 结果为:()A
hi howdy dude!B
运行时异常被抛出。C
第7行出现一个错误,编译失败。D
第8行出现一个错误,编译失败。
考题
单选题class Guy { String greet() { return "hi "; } } class Cowboy extends Guy { String greet() { return "howdy "; } } class Wrangler extends Cowboy { String greet() { return "ouch! "; } } class Greetings2 { public static void main(String [] args) { Guy g = new Wrangler(); Guy g2 = new Cowboy(); Wrangler w2 = new Wrangler(); System.out.print(g.greet()+g2.greet()+w2.greet()); } } 结果是什么?()A
hi hi ouch!B
hi howdy ouch!C
ouch! howdy ouch!D
编译失败
考题
单选题若有定义String tom=""boy"";String hill=""boy"";则表达式(tom==hill)的值为()A
TrueB
FalseC
1D
0
热门标签
最新试卷