题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-03-17 06:17:40

[简答题]下面程序是关于类的继承的用法。阅读下面程序,根据程序中的注释在每一条横线处填写一个语句,使程序的功能完整,且运行程序后的输出结果为:
I am parentclass!
I am childclass!
I am childclass!
注意: 请勿改动main( )主方法和其他已有的语句内容,仅在下划线处填入适当的语句。
class Parent
void printMe( )
System.out.println("I am parentclass!");


class Child extends Parent
void printMe( )
System.out.println("I am childclass!");

void printAll( )
______________.printMe ( ); // 调用父类的方法
______________. printMe ( ); //调用本类的方法
printMe ( );


public class TestJieCheng
public static void main(String args[])
______________
myC.printAll( );


更多"下面程序是关于类的继承的用法。阅读下面程序,根据程序中的注释在每一条横"的相关试题:

[简答题]下面程序是关于类的继承的用法。阅读下面程序,根据程序中的注释在每一条横线处填写一个语句,使程序的功能完整,且运行程序后的输出结果为:
I am parentclass!
I am childclass!
I am childclass!
注意:请勿改动main( )主方法和其他已有的语句内容,仅在下划线处填入适当的语句。
class Parent
void printMe( )
System. out. println( "I am parentclass ! ");


class Child extends Parent
void printMe( )
System. out. println( "I am childclass! ")

void printAll( )
______. printMe( ); //调用父类的方法
______. printMe( ); //调用本类的方法
printMe ( );


public class TestJieCheng
public static void main(String args[])
______
myC. printAll( );


[填空题]下面的程序用“冒泡”法将数组a中的10个整数按升序排列,请在横线处将程序补充完整。
public class Sun
public static void main(String args [])
int [] a=678,45,324,528,439,387,87,875,273,823;
int a1=0;
for(int i=0i<=8;i++)
for(int j= 【13】 ;j<=9;j++)
if (a [i]>=a[j])
a1=a[j];
a[j]=a[i];
a[i]=a1;


for(int i=0;i<=9;i++)
System.out.println(a[i]);


[填空题]下面的程序用“冒泡”法将数组a中的10个整数按升序排列,请在横线处将程序补充完整。
public class Sun
public static void main(String args[])
int[] a=678,45,324,528,439,387,87,875,273,823 ;
int a1=0;
for(int i=0; i<=8;i++)
for(int j= 【12】 ;j<=9;j++)
if(a[i]>=a[j])
a1=a[j];
a[j]=a[i];
a[i]=a1;


for(int i=0;i<=9;i++)
System. out. println(a[i]);


[简答题]在下面程序横线处填上适当内容,使程序执行结果为:40:15程序如下:
#include<iostream.h>
template<class T>
T func(T x,T y)
if(sizeof(T)= =8)
return______;
else
return______;

void main( )
cout<<func(8,5)<<":"<<func(5.0,10.0)<<endl;
int d;cin>>d;

[简答题]在下面程序横线处填上适当内容,使程序执行结果为:
n=9
程序如下:
#include<iostream.h>
template<class T>
class Test

T n;
public:
Test( )
Test(T i)n=i;
Test<T>______(const Test <T> &s)

static Test<T>temp:
______;
return temp;

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

void main( )

Test<int>t1(4),t2(5),t3;
t3=t1+t2:
t3.disp( );

[填空题]在下面程序横线处填上适当内容,使得程序的输出为9876。
#include <iostream>
using namespace std;
template<class T>
void f( 【12】 )

T t;
for (int i=0;i<n/2;i++)

t=a Ii];
a [i]=a[n-1-i];
a [n-1-i]=t;


int main ( )

int x[]=6,7,8,9;
f(x,4);
for (int i=0;i<4;i++)
cout<<x[i];
cout<<end1;
return 0;

[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为: TIME=1867 b=9 i=123 注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。 import java.io.*; public class DataType{ public______________void main(String args[]) { byte b; int i;//定义变量i为int类型 ___________________________ //定义常量TIME为整型,且值为1867 i=123;//给变量i赋值,该值为十进制的123 __________________________________//给变量赋值,改值为,八进制的11,十进制的9 System.out.println("TIME”+TIME); System.out.println("b="+b); System.out.println("i="+i); } }
[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为:
TIME=1867
b=9
i=123
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
import java.io.*;
public class DataType

public ______ void main(String args[])

byte b;
int i;//定义变量i为int类型
______//定义常量TIME为整型,且值为1867
i=123;//给变量i赋值,该值为十进制的123
______//给变量赋值,改值为八进制的11,十进制的9
System.out.println("TIME"+TIME);
System.out.println("b="+b);
System.out.println("i="+i);


[填空题]在下面程序的横线处填上适当的语句,使该程序的输出为12。 #include <iostream> using namespace std; class Base { public: int a; Base(int i){a=i;} }; class Derived: public Base { int a; public: Derived(int x): Base(x),b(x+l){} void show( ) { 【11】 ;∥输出基类数据成员a的值。 cout<<b<<end1; } }; int main( ) { Derived d(1); d.show( ); return 0; }
[简答题]在下面程序横线处填上适当内容,使程序执行结果为:200_ _100。
#include<iostream.h>
template<class T>
T f(______)
if(______)
return x+y;
else
return x*y;

void main( )
cout<<f(10,20)<<"_ _"<<f(45.5,54.5)<<endl;
[简答题]下面程序的功能是输出字符串“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.________________));


[简答题]在下面程序的横线处填上适当内容,使程序执行结果为:"hello,andylin"。
#include<iostream>
#include<string.h>
using namespace std;
class mystring
public:
char*pdata;
mystring(int len)
pdata=new char[len+1];
~mystring( )
delete pdata;
void show( )cout<<pdata<<endl;

void fun(mystring**array,int len)
mystring*old=*array;
______
memcpy(*array,old,len);

void main( )
mystring str(20);
mystring*pstr=&str;
mystring**ppstr=&pstr;
strcpy(str.pdata,"hello,andylin");
fun(ppstr,20);
______

我来回答:

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

订单号:

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