题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-11-25 19:09:04

[填空题]

请将下面程序补充完整。
public class PowerCalc{
public static void main(String[]args){
double x=5.0;
System. out. println(x+"to the power 4 is"+power(x, 4));
System. out. println("7. 5 to the power 5 is"+power(7.5, 5));
System. out. println("7.5 to the power 0 is"+power(7.5, 0));
System. out. println("10 to the power -2 is"+power(10, -2));
}
static double 【11】 (double x, int n){
if(n>1)
return x * power(x, n-1);
else if(n<0)
return 1.0/power(x, -n);
else
return n==0 1.0:x;
}
}


更多"请将下面程序补充完整。 public class PowerCalc{"的相关试题:

[单项选择]阅读下面程序:
public class ThreadTest
 public static void main(String args[]) throws Exception
  int i=0;
  Hello t=new Hello( );
  ______;
  While(true)
   System.out.println("Good Morning"+i++);
   if(i==2&&t.isAlive( ))
    System.out.println("Main waiting for Hello!");
    t.join( ); //等待t运行结束
   
   If(i==5)break:
  

class Hello extends Thread
  int i;
  public void run( )
  while(true)
    System.out.println("Hello"+i++):
    If(i==5)break;
  
 

为使该程序正确执行,下画线处的语句应是
A. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]阅读下面程序
public class Increment
public static void main(stringargs[])
int c;
c=5:
System.out.println(c);
System.out.println(c++);
System.out.println(c);


程序运行结果是( )。
A. 5
B. 5
C. 6
D. 6
[单项选择]阅读下面程序 public class VariableUse {  public static void main(String[] arqs) {   int a;   if(a==8) {    int b=9;    System.out.println("a="+a);    System.out.println("b="+b);   }   System.out.println("a="+a);   System.out.println("b="+b):  } } 该程序在编译时的结果是
A. 变量a未赋值
B. 第二个System.out.println("b="+b);语句中,变量b作用域有错
C. 第二个System.out.println("a="+a);语句中,变量a作用域有错
D. 第一个System.out.println("b="+b);语句中,变量b作用域有错
[单项选择]请阅读下面程序
public class ThreadTest
public static void main(String args[])throws Exception
int i=0:
Hello t=new Hello( );
_________;
while(true)
System.out.println("Good Morning"+i++);
if(i==2&&t.isAlive( ))
System.out.println("Main waiting for Hello!");
t.join( );//等待t运行结束

if(i==5)break;)


class Hello extends Thread
int i;
public void run( )
while(true)
System.out.println("Hello"+i++);
if(i==5)break;
为使该程序正确执行,下画线处的语句应是( )。
A. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]有下面程序段:
Public class ArrayTest

Public static void main(String args[])

int[] intArray=new int[3];
for(int I=0;I<3;I++)

intArray[I]=I+2;
System.out.println("IntArray["+I+"]"="+intArray[I]);

System.out.println("--------------");
Int arrLen=4;
IntArray=new int[arrLen];
For(int j=intArray.length;j>=0;j--)

intArray[j]=j*3;
System.out.println("hello"+intArray[j]);



则运行的结果是( )。
A. 编译出错
B. 编译通过,但运行出错
C. 可以运行,但有错误
D. 以上都不对
[单项选择]阅读下面程序
public class Test3
public static void main(String args[])
int x=3, y=4, z=5;
String s="xyz";
System.out.primln(s+x+y+z);


程序运行的结果是
A. xyzl2
B. xyz345
C. xyzxyz
D. 12xyz
[填空题]下面程序的输出结果为:Base::fun,请将程序补充完整。 #include<iostream.h> class Base{ public: 【12】 fun( ){cout<<"Base::fun"<<end1;} }; class Derived:public Base{ public: 【13】 fun( ){cout<<"Derived::fun"<<end1;} }; int main( ) { Base a,*pb; Derived b; pb=&b; pb->tim( ); return 0; }
[填空题]下列程序的输出结果为2,请将程序补充完整。
using namespace std;
class Base
public:
【12】 void fun( ) cout<<1;
;
class Derived:public Base

public:
void fun( ) cout<<2;
int main( )

Base*p=new Derived;
p->fun( );
delete p;
return 0’;

[填空题]

请将下面的程序补充完整,使得程序输出“飘是张娜的书”。
  #include
  using namespace std;
  class Book{
  public:
  Book(char *str) {strcpy(title,str);}
  【1】 void PrintInfo( ) {cout<
  protected:
  char title[50];
  };
  class MyBook:public Book{
  public:
  MyBook(char *s1,char *s2="张娜"):
【2】 {strcpy(owner,s2);}
  virtual void PrintInfo( ) {cout<
  private:
  char owner[10];
  };
  int main( ){
  Book *prt=new MyBook("飘");
  prt->PrintInfo( );
  return 0;
  }

2()
[填空题]下面程序段是从对象流中读取对象,请将程序补充完整。
importjava.util.*;
importjava.io.*;
publiclass UnSerializaDate
Dated=null;
UnSerializaDate( )
try
FilelnputStreamf=newFilelnputStream("date.ser");
ObjectlnputStreams=newObjectlnputStream(f);
f.close( );

catch(Exceptione)
e.printStackTrace( );


public staticvoidmain(Stringargs[])
publicstaticvoidmain(Stringargs[])
UnSerializaDatea=newUnSerializaDate( );
System.out.println("Thedatereadis:"+a.d.toString( ));


[填空题]请阅读下面程序 public class Test { public static void main (String[] args) { int i,j; for (i=1;i<5;i++) { for (j=1;j<=i;j++) system.out.print (i+"X"+j+"="+i*j+" "); System.out.println( ); } } } 程序执行完后,i循环和j循环执行的次数分别是 【12】
[单项选择]

请阅读下面程序
public class ThreadTest{
public static void main(String args[]) {
Thread t1=new Thread(new Hello( ));
Thread t2=new Thread(new Hello( ));
t1.start( );
t2.start( );
}
}
class Hello implements Runnable {
int i;
public void run( ) {
while(true) {
System.out.prinfin("Hello"+i++);
if(i=5) break;
}
}
}
该程序创建线程使用的方法是()


A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.start()
[单项选择]

请阅读下面程序
public class ThreadTest {
public static void main(String args[]) throws Exception{
int i=0;
Hello t=new Hello( );
____;
while(true) {
System.out.println("Good Moming"+i++);
if (i==2 && t.isAlive( )) {
System. out.println("Main waiting for Hello!");
t.join( ); //等待t运行结束
}
if(i==5) break;
}
}
}
class Hello extends Thread {
int i;
public void run( ) {
while(true){
System.out.println("Hello"+i++);
if (i==5) break;
}
}
}
为使该程序正确执行,下划线处的语句应是()


A. sleep()
B. yield()
C. interrupt()
D. start()
[填空题]

请将下面的程序补充完整,使得程序输出“飘是张娜的书”。
#include
using namespace std
class Book
public:
Book(char*str)|strcpy(title,str);
______void Printlnfo( )cout<<title<<endl;
protected:
char title[50];

class MyBook:public Book
public:
MyBook(char*s1,char*S2=“张娜”):
______strcpy(owner,s2);
virtual void PrintInfo( )cout<<title<<“是”<<owner<<“的书”<<endl;
private:
charowner[10];

int main( )
Book*ptr=new MyBook(“飘”);
ptr->Printlnfo( );
return 0;


我来回答:

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

订单号:

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