题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-09 23:40:12

[填空题]请在下列程序中的空格处填写正确的语句:
class Sample
public:
Sample( )
~Sample( )
void SetData(int datA) //将Sample类成员变量data设置成形参的值
______

private:
int data;

更多"请在下列程序中的空格处填写正确的语句: class Sample "的相关试题:

[填空题]有如下类定义:
class Sample
public:
Sample( );
~Sample( );
private:
static int data;

将静态数据成员data初始化为0的语句是______。
[填空题]请在如下程序中的空格处填写正确的语句;
#include<iostream>
using namespaee std;
c]ass Base
public:
void fun( )cout<<"Base fun"<<endl;

class Derived:public Base
public:
void fun( )
______//调用基类的函数fun( )
cout<<"Derived fun"<<endl;


[单项选择]有如下类的定义。空格处的语句是( )。 class MyClass { ____________ int x, y; public: MyClass(int a=0,int b=0) { x=a; y=b; } static void change( ) { x-=10; y-=10; } };
A. static
B. const
C. private
D. 不需要填入内容
[填空题]以下程序的执行结果是______。
#include<iostream.h>
class Sample

int n;
public:
Sample( )
Sample(int m)n+m;)
int&operator--(int)

n--
return n;

void disp ( ) cout<<"n= "<<n<<end1;

void main ( )

Sample s (10);
(s--) ++;
s.disp( );

[填空题]以下程序的执行结果是______。
#inelude<iostream.h>
class Sample

public:
int x;
int y;
void disp( )

cout<<"x="<<x<<",y="<<y<<endl;

;
void main( )

int Sample::*pc;
Sample s;
pc=&Sample::x;
s.*pc=10;
pc=&Sample::y;
s.*pc=20;
s.disp( );

[单项选择]有如下类的定义。那么空格处的语句是( )。
class MyClass

____________int x,y;
public:
MyClass(int x1=0,int y1=0)

x=x1;
y=y1;

static void change( )

x+=10;
y+=10;


A. static
B. const
C. private
D. 不需要填入内容
[单项选择]有如下类的定义。应在空格处填入的语句是 ( )。
class MyClass

______________ int x, y;
public:
MyClass(int a=0,int b=0)

x=a;
y=b;

static void change)

x-=10;
y-=10;
;
A. static
B. const
C. mutable
D. 不需要填入内容
[简答题]下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适当的语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class InputString
public static void main(String args[ ])
String stringname= new _______________ ("ABCDEFGH");
for(int i= _______________ i>=0;i--)
System.out.println(String.valueOf(stringname.________________));


[简答题]下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。 注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。 ____________________ public class TestKeyBoardInPut {public static void main(String[] args) {String yourname=JOptionPane. ____________________ ("What is your name"); System.out.println("Hello"+yourname); ____________________.exit(0); } }
[简答题]下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
public class DoWhileLoop

public static void main(________)

int n=10;
long result=1;
do

_______________

______________
System.out.println("10的阶乘为: "+result);


[简答题]下面的程序是用do-while语句计算10的阶乘。请在程序的每条横线处填写1个语句,使程序的功能完整。 注意:请勿改动main( )主方法和其他已有的语句内容;仅在横线处填入适当的语句。 源程序文件代码清单如下: public class DoWhileLoop { public static void main(______) { int n=10; long result=1; do { _____; } _____; System.out.println("10的阶乘为:"+result); } }
[简答题]下面程序是关于位运算符的使用。请在程序的每条横线处填写适当的语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的位运算符。
public class BitOperator
public static void main(String args[ ])
int a=9; //二进制数1001
int b=15; //二进制数1111
int c=8; //二进制数1000
int d,e, f,g,h;
d=a _____________________ b;//二进制数1001, 也就是十进制数9
e=a|b;//二进制数1111, 也就是十进制数15
f=a _____________________ b;//二进制数0110, 也就是十进制数6
g=a<<2 / /; 9×4=36
h=c_______________________1;//8/2=4
System. out .println ( "d="+d);
System. out .println ( "e="+e);
System. out .println ( "f="+f);
System. out .println ( "g="+g);
System. out .println ( "h="+h);


[填空题]填写完整下面程序中所缺的部分。
class myfirst

【14】

System.out,println("This is my first Java Application");


[简答题]下面的程序的功能是求1~100的奇数的和及该和的平均值。请在程序的每条横线处填写一个语句,程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
public class SumAndAve
public static void main(String args[ ])
int count=0,sum=0,ave=0;
for(int i=1;i<=100;____________________)
if(_____________________)
continue;
else

___________________
sum=sum+i;

ave=sum/count;
System.out.println("sum="+sum);
System.out.println("ave="+ave);


[填空题]请填写完整下面程序中所缺的部分。
class myfirst

【14】

System.out,println("This is my first Java Application");


我来回答:

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

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码