题目详情
当前位置:首页 > 计算机考试 > 中级软件设计师
题目详情:
发布时间:2023-10-28 04:33:19

[简答题]

[C++代码]
class Product { //产品
private:
string pid; //产品识别码
string description; //产品描述
double price; ///产品单价
public:
void setProductPrice(double price); //设置产品单价
string getProduetld( ); //获取产品识别码
string getProduetDescriprion 0; //获取产品描述
double getProductPrice0; //获得产品单价
//其他成员省略
};
class ProductList { //产品列表类
private:
vector <Product> products;
public:
ProductList( );
Product getProductBylndex(int i); //获得产品列表中的第i件产品
void addProduct(Product t); //在产品列表中加入一件产品
Product * getProductByID(string pid); //获得识别码为pid的产品指针
unsigned iht getProductAmount( ); //获得产品列表中的产品娄量
};
class OrderItem { //订单条目类
private:
Product *productPtr; //指向被订购产品的指针
int quantity; //订购数量
public:
OrderItem (Product *,iht);
Product * getProductptr O; //获得指向被订购产品的指针
int getQuantity ( ); //获取被订刚强产品数量
};
class Order { //订单类
priva

更多"[C++代码] class Product { //产品 privat"的相关试题:

[单项选择]假设有以下代码:
String s="hello";
String t="hello";
char c[]='h', 'e', 'l', 'l', 'o';
下列选项中,返回false的语句是______。
A. s.equals(t);
B. t.equals(c);
C. s==t;
D. t.equals (new String("hello"));
[单项选择]以下程序代码的输出结果是( )
String s=new String("abcdef"),t=new String("123");
System. out. println((concat(s,t)). length( ));
A. 9
B. 10
C. 6
D. 出错
[单项选择]指出下列程序运行的结果 ( )
public class Example
String str=new String("good");
char[]ch=’a’,’b’,’c’;
public static void main(String args[])
Example ex=new Example( );
ex.change(ex.otr,ex.ch);
System.out.print(ex.str+"and");
System.out.print(ex.ch);

public void change(String str,char ch[])
str="test ok";
ch[0]≈’g’;


A. good and abc
B. good and gbc
C. test ok and abc
D. test ok and gbc
[单项选择]下列程序的运行结果是()  public class test{  private String[] data={“10”,“10.5”};  public void fun(){  double s=0;  for(int i=0;i<3;i++){  try{  s=s+Integer .parseInt(data[i]);  }catch(Exception e){  System.out.print(“errorl:”+data[i]);  }  }  }  public static void main(String[]args){  try{  testd=new test();  d .fun();  }catch(Exception e){  System.out.printIn(“error2”);  }  }  }
A. errorl:10.5
B. error2
C. errorl:10.5 error2
D. 以上都不对
[填空题]下面是一个类的定义,试将程序补充完整。
class Test
String s;
【12】 int a =66;
Test(String s1)
s=s1;

static int geta( )
return a;


[简答题]阅读以下程序代码,写出程序的功能。
public class Class34

public static void main(String[] args)

int a=1,b;
while(a<=9)

b=1;
while(b<=a)

System. out. print(" "+a+"×"+b+"="+a*b);
b++;

System. out. println( );
a++;



[单项选择]下列代码段声明了3个类:
class Person;
class Student:public Person;
class Undergraduate:Student;
下列关于这些类之间关系的描述中,错误的是( )。
A. 类Person是类Undergraduate的基类
B. 类Undergraduate从类Student公有继承
C. 类Student是类Person的派生类
D. 类Undergraduate是类Person的派生类
[填空题]下列是一个类的定义,将程序段补充完整。    class A {     String s;     【 】int a=66;    A(String sl) { s=sl;}    static int geta( ) { return a;}   }
[简答题]阅读以下程序代码,写出程序的输出结果。
public class Class35

public static void main(String[] args)

String s1=new String("0860371"),s2="0860371";
System. out. println(s1==s2);
System. out. println(s1. equals(s2));
System. out. println(s1. endsWith(s2)==s1. startsWith(s2));


[简答题]阅读以下程序代码,写出程序的输出结果。
public class Class32

public static void main(String[] args)

boolean x=true,y=false,z=false;
x=x&&y||z;
y=x||y&&z;
z=!(x!=y)||(y==z);
System. out. println(x+","+y+","+z);


[简答题]阅读以下程序代码,写出程序的输出结果。
public class Class33

public static void main(String[] args)

int a,b,c;
a=b=c=1;
boolean w;
w=a++>1&&++b>c++:
System. out. println(a+","+b+","+c+","+w);


[单项选择]下面代码不合法之处是( )
class Class6

int x;
void f( )

int class 6=1;①
x=class 6;②

void g( )

int y;③
y=class6+x;④


A. 语句①
B. 语句②
C. 语句③
D. 语句④
[单项选择]阅读下面代码
public class Arrays
 public static void main(String[] args)
  int[] a=new int[5];
  for(int i=0;i<a.length;i=i+1)a[i]=10+i;
  for(int i=0;i<a.length;i=i+1)System.out.println(a[i]);
  String[] s="Frank","Bob","Jim";
  for(int i=0;i<s.length;i=i+1)System.out.println(s[i]);
  s[2]="Mike";
  System.out.println(s[2]);
 

代码运行正确的结果是
A. 10
B. 11
C. 10
D. 11
[单项选择]阅读下面代码
public class Jixiangwu
 public static void main(String[] args)
  String[] stars="贝贝","晶晶","欢欢","迎迎","妮妮";
  System.out.println("你抽取的奥运吉祥物是"+
  "“"+stars[(int)(stars. ______ *Math.random( ))]+"”"+"!");
 

为保证程序能正确执行,程序中下画线处应填写的是
A. long
B. width
C. wide
D. length
[单项选择]阅读下面代码
public class Test implements Runnable
 public void run(Thread t)
  System.out.println("Running");
 
public static void main(String[] args)
  Thread tt=new Thread(new Test( ));
  tt.start( );
 

代码运行的结果是
A. 将抛出一个异常
B. 没有输出并正常结束
C. 输出“Running”并正常结束
D. 程序第2行将出现一个编译错误

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码