重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
当前位置: 首页 > 计算机类考试 > 软考中级
网友您好, 请在下方输入框内输入要搜索的题目:
搜题

题目

[主观题]

阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。 [说明] 编写一个完整的JavaApplet

阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。

[说明] 编写一个完整的JavaApplet 程序使用复数类Complex 验证两个复数1+2i 和3+4i 相加产生一个新的复数4+6i。

复数类Complex 必须满足如下要求:

(1) 复数类Complex 的属性有:

RealPart: int 型,代表复数的实数部分

ImaginPart: int 型,代表复数的虚数部分

(2) 复数类Complex 的方法有:

Complex():构造函数,将复数的实部和虚部都置0

Complex (intr,inti):构造函数,形参r为实部的初值,i为虚部的初值。

ComplexeomplexAdd (Complexa):将当前复数对象与形参复数对象相加,所得的结果仍是一个复数值,返回给此方法的调用者

String ToString():把当前复数对象的实部、虚部组合成s+ bi 的字符串形式,其中a和b分别为实部和虚部的数据。

importjava. applet. * ;

importjava. awt. * ;

publicclassabcextends Applet

{

Complex a, b, c;

publi cvoid init()

{

a = newComplex(1,2);

b = newComplex(3,4);

c = newComplex();

}

publievoidpaint (Graphicsg)

{

(1)

g. drawstring(“第一个复数:” + a. toString(), 10,50);

g. drawstring(“第二个复数:” + b. toString(), 10,70 );

g. drawstring(“两复之和:” + c. toString(), 10,90);

}

}

class Complex

{

int RealPart;

int ImaginPart;

Complex() { (2) }

Complex(intr , inti)

{ (3) }

ComplexeomplexAdd (Complexa)

{

Complextemp = newComplex();

temp. BealPart = RealPart + a. BealPart;

(4)

returntemp;

}

public StringtoString()

{ return(RealPart + " + " + ImaginPart + " i "); }

}

查看参考答案
更多“阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。 [说明] 编写一个完整的JavaApplet”相关的问题

第1题

阅读以下说明和Java码,将应填入(n)处的字名写在对应栏内。 [说明] 编写一个字符界面的Java Applic

阅读以下说明和Java码,将应填入(n)处的字名写在对应栏内。

[说明] 编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。

import java. io. * ;

public class abc

{

public static void main(String args [ ] )

{ int i, n = 10 , max = 0 , min = 0 , temp = 0;

try {

BufferedReader br = new BufferedReader(

new InputStreamReader(System. in) );

(1));

} catch (IOException e ) { } ;

for(i = 2 ;i <= n; i ++ ) {

try {

BufferedReader br = new BufferedReader(

new InputStreamReader (System. in) );

temp = Integer. parselnt(br. readLine() );

if (temp > max ) (2)

if (temp < min) (3)

} catch (IOExeeption e ) { } ;

System. out. println("max =" + max + "\nmin =" + min);

}

}

点击查看答案

第2题

阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。 [说明] 打印输出10行杨晖三角形。形

阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。

[说明] 打印输出10行杨晖三角形。形式如下:

杨晖三角形:

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

1 7 21 35 35 21 7 1

1 8 28 56 70 56 28 8 1

1 9 36 84 126 126 84 36 9 1

class yanghui

{

public static void main (String args [] )

{

int i, j;

(1)

int yanghui [] [];

System. out. println(“杨晖三角形:” );

yanghui = new int [ yhleve1] [];

for(i =0;i < yanghui, length; i + + )

yanghui[i] = new int [i + 1];

(2)

for((3))

{

yanghui [i] [0] = 1;

for(j = 1 ;j < yanghui[i], length - 1 ;j + + )

yanghui[i] [j] = yanghui[i - 1] [j - 1] + yanghui[i - 1] [j];

yanghui[i] [yanghui[i]. length - 1 ] = 1;

}

for (i=0; i < yanghui. length; i + + )

{

for(j =0;j < yanghui[i]. length; j + + )

(4)

System. out. println();

}

}

}

点击查看答案

第3题

() 阅读下列说明和JAVA代码,将应填入空(n)处的字句写在答题纸的对应栏内。【说明】 某中学开展中外

() 阅读下列说明和JAVA代码,将应填入空(n)处的字句写在答题纸的对应栏内。【说明】 某中学开展中外中学生野外生存夏令营活动,由于中外学生的语言障碍,随队为外籍学员配置一名翻译。以下代码采用适配器(Adapter)模式模拟翻译适配器。其类图如下:() 阅读下列说明和JAVA代码,将应填入空(n)处的字句写在答题纸的对应栏内。【说明】 某中学开展

点击查看答案

第4题

阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。 [说明] 编写一个学生类Student,要求

阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。

[说明] 编写一个学生类Student,要求:

(1) 学生类Student 属性有:

id: long 型,代表学号

name: String类对象,代表姓名

age: int 型,代表年龄

sex: boolen 型,代表性别(其中:true 表示男,false 表示女)

phone: String 类对象,代表联系电话

(2) 学生类Student 的方法有:

Student (long i,String n,int a,boolean s,String p)

:有参构造函数,形参表中的参数分别初始化学号、姓名、

年龄、性别和联系电话。

int getAge ():获取年龄作为方法的返回值。

boolean getSex ():获取性别作为方法的返回值。

String getPhone ():获取联系电话作为方法的返回值。

public String to String ():以姓名:性别:学号:联系电话的形式作为方法的返

import java. applet. Applet;

import java. awt.* ;

public class Student extends Applet {

long id;

String name, phone;

int age;

boolean sex;

Student(long i, String n, int a, boolean s, String p)

{

id=i;

name = n;

age = a;

sex= s;

phone = p;

{

public void paint(Graphics g)

{

Student x= new Student (5000," xiaoliu" , 89, true, " 8989898" );

(1);

(2)

g. drawstring(x. getPhone(), 140,140);

}

int getAge()

{ return age; }

boolean getsex ()

{ return sex; }

String getPhone()

{ return phone; }

String ToString()

{

(3)

}

}

点击查看答案

第5题

阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序实现十进制向其它

阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。

[说明]

下面程序实现十进制向其它进制的转换。

[Java程序]

ClasS Node{

int data;

Node next;

}

class Transform{

private Node top;

public void print(){

Node p;

while(top!=null){

P=top;

if(P.data>9)

System.out.print((char)(P.data+55));

else

System.out.print(p.data);

top=p.next;

}

}

public void Trans(int d,int i){//d为数字;i为进制

int m;

(1) n=false;

Node p;

while(d>0){

(2);

d=d/i;

p=new Node();

if((3) ){

p.data=m;

(4);

top=P;

n=true;

}

else{

p.data=m;

(5);

top=P;

}

}

}

}

点击查看答案

第6题

阅读以下说明和c++码,将应填入(n)处的字名写在的对应栏内。 [说明] 以下函数完成求表达式 的值,

阅读以下说明和c++码,将应填入(n)处的字名写在的对应栏内。

[说明] 以下函数完成求表达式

阅读以下说明和c++码,将应填入(n)处的字名写在的对应栏内。 [说明] 以下函数完成求表达式 的值

的值,请填空使之完成此功能。

float sum (float x )

{ float s=0.0;

int sign = 1;

(1);

for(inti=1;(2); i+ +)

{

t=t*x;

s=s+(3);

sign = - sign;

(4);

}

点击查看答案

第7题

阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。 [说明] 以下程序为类类型的变量应

阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。

[说明]

以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。

[JAVA代码]

//定义自己的异常类

class CCircleException extends Exception

{

}

// 定义类 CCircle

class CCircle

{

private double radius;

public void setRadius (double r ) (1)

{

if (r<0 ) {

(2)

}

else

(3)

}

Public void show () {

System. out. println ("area="+3.14*radius*radius );

}

}

public class ciusample

{

public static void main (String args[] )

{

CCircle cir=new CCircle();

(4) {

cir. setRadius (-2.0 )

}

(5)

{

System. out. println (e+" throwed" ) ;

}

cir. show() ;

}

}

点击查看答案

第8题

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。[说明] 编写一个字符界面的Java Appli

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。

[说明]

编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。

[Java 代码]

import java. io.* ;

public class abc

{

public static void main ((1))

{int i, n=10, max=0, min=0, temp=0;

try {

BufferedReader br = new BufferedReader (

new InputStreamReader (System.in ) );

max = min =Integer. parselnt (br. readLine () );

}. (2) (IOExccption e ) {} ;

for (i=2 ; i<=n ; i++ ) {

try {

BufferedReader br = new (3) (

new InputStreamReader (System. in ) );

temp =(4) (br. readLine ());

if (temp>max ) max=temp;

if (temp<min) (5)

} catch (IOException e ) {};

}

System.out.println ("max="+max+"\nmin="+min );

}

}

点击查看答案

第9题

阅读以下说明、Java代码,将应填入(n)处的字句写在对应栏内。【说明】 本程序输出10000之内的所有完全

阅读以下说明、Java代码,将应填入(n)处的字句写在对应栏内。

【说明】

本程序输出10000之内的所有完全数。完全数是指等于其所有因子和(包括1,但不包括这个数本身)的数。例如:6=1×2×3,6=1+2+3,则6是一个完全数。

【程序】

public class PerfectNum

{

Public static void main(String args[])

{

int count=1;

for(int i=1; i<10000; i++)

{

int y=0;

for(int j=1; j<i; j++)

if((1))

y=(2)

if((3))

{

System.out.print((4) +String.valueOf('\t'));

(5)

If(count%3==0)

System.out.printin();

}

}

}

点击查看答案

第10题

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。【说明】 下面程序完成从键盘读入一个字

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。

【说明】

下面程序完成从键盘读入一个字符串,然后采用parseInt方法将其转换为一个相应的整数。

import java.io.*;

public class testThrows{

public static (1) readString() (2) IOException{

int ch;

String r="";

boolean done=false;

while((3)){

ch=System.in.read();

if(ch<0 || ch=0xd) //处理回车符中第一个符号

done=true;

else

r=r+(char)ch;

}

return r;

}

public static void main(Stling args[]){

String str;

(4) {

str=readString();

} (5) (IOException e){

System.out.println("error");

return;

}

System.out.println("input integer: "+Integer.parselnt(str));

}

}

点击查看答案
赏学吧APP
TOP
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)
订单号:
遇到问题请联系在线客服
请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

- 微信扫码关注赏学吧 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反赏学吧购买须知被冻结。您可在“赏学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注赏学吧 -
请用微信扫码测试
温馨提示
每个试题只能免费做一次,如需多次做题,请购买搜题卡
立即购买
稍后再说
赏学吧