网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
public class Mycircle {   public double radius;   public double diameter;   public void setRadius(double radius)   this.radius = radius;   this.diameter= radius * 2;   }   public double getRadius() {  return radius;   }   Which statement is true?()
A

 The Mycircle class is fully encapsulated.

B

 The diameter of a given MyCircle is guaranteed to be twice its radius.

C

 Lines 6 and 7 should be in a synchronized block to ensure encapsulation.

D

 The radius of a MyCircle object can be set without affecting its diameter.


参考答案

参考解析
解析: 暂无解析
更多 “单选题public class Mycircle {   public double radius;   public double diameter;   public void setRadius(double radius)   this.radius = radius;   this.diameter= radius * 2;   }   public double getRadius() {  return radius;   }   Which statement is true?()A  The Mycircle class is fully encapsulated.B  The diameter of a given MyCircle is guaranteed to be twice its radius.C  Lines 6 and 7 should be in a synchronized block to ensure encapsulation.D  The radius of a MyCircle object can be set without affecting its diameter.” 相关考题
考题 阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】下面的程序先构造Point类,再顺序构造Ball类。由于在类Ball中不能直接存取类Point中的xCoordinate及yCoordinate属性值,Ball中的toString方法调用Point类中的toString方法输出中心点的值。在MovingBall类的toString方法中,super.toString调用父类Ball的toString方法输出类Ball中声明的属性值。public class Point{private double xCoordinate;private double yCoordinate;public Point 0 }public Point(ouble x, double y){xCoordinate = x;yCoordinate = y;}public String toString(){return "( + Double.toString(Coordinate)+ ","+ Double.toString(Coordinate) + ");}//other methods}public class Ball{(1); //中心点private double radius; //半径private String colour; ///颜色public Ball() { }public Ball(double xValue, double yValue, double r)// 具有中心点及半径的构造方法{center=(2);//调用类Point 中的构造方法radius = r;}public Ball(double xValue, double yValue, double r, String c)// 具有中心点、半径及颜色的构造方法{(3);//调用3个参数的构造方法colour = c;}public String toString(){return "A ball with center" + center, toString() + ", radius"+ Double.toString(radius) + ", colour" + colour;}//other methods}public class MovingBall. (4){private double speed;public MovingBall() { }public MovingBall(double xValue, double yValue, double r, String e, double s){(5);// 调用父类Ball中具有4个参数的构造方法speed = s;}public String toString( ){ return super, toString( ) + ", speed "+ Double.toString(speed); }//other methods}public class Tester{public static void main(String args[]){MovingBall mb = new MovingBall(10,20,40,"green",25);System.out.println(mb);}}

考题 ( 13 )补充完整下面的类定义:const double PI=3 .14;class Circle{ // 圆形物体的抽象基类protected:double r; // 半径public:Circle ( double radius=0 ) : r ( radius ) {}【 13 】 ; // 计算圆形物体表面积的纯虚函数声明};class Cylinder:public Circle { // 圆柱体类double h; // 高度public:Cylindr ( double radius=0, doubli height=0 ) :Circle ( radius ) , h ( height ) {}Virtual double Area () { // 计算圆柱体的表面积return 2*PI*r* ( r+h ) ;}};

考题 阅读以下函数说明和Java代码,将应填入(n)处的字句写在对应栏内。【说明】下面的程序先构造Point类,再顺序构造Ball类。由于在类Ball中不能直接存取类Point中的xCoordinate及yCoordinate属性值,Ball中的toString方法调用Point类中的toStrinS方法输出中心点的值。在MovingBsll类的toString方法中,super.toString调用父类Ball的toString方法输出类Ball中声明的属性值。【Java代码】//Point.java文件public class Point{private double xCoordinate;private double yCoordinate;public Point(){}public Point(double x,double y){xCoordinate=x;yCoordinate=y;}public String toStrthg(){return"("+Double.toString(xCoordinate)+","+Double.toString(yCoordinate)+")";}//other methods}//Ball.java文件public class Ball{private (1);//中心点private double radius;//半径private String color;//颜色public Ball(){}public Ball(double xValue, double yValue, double r){//具有中心点及其半径的构造方法center=(2);//调用类Point中的构造方法radius=r;}public Ball(double xValue, double yValue, double r, String c){//具有中心点、半径和颜色的构造方法(3);//调用3个参数的构造方法color=c;}public String toString(){return "A ball with center"+center.toString()+",radius "+Double.toString(radius)+",color"+color;}//other methods}class MovingBall (4) {private double speed;public MovingBall(){}public MoyingBall(double xValue, double yValue, double r, String c, double s){(5);//调用父类Ball中具有4个参数的构造方法speed=s;}public String toString(){return super.toString()+",speed"+Double.toString(speed);}//other methods}public class test{public static void main(String args[]){MovingBall mb=new MovingBall(10,20,40,"green",25);System.out.println(mb);}}

考题 下列程序的执行结果为【 】。include class Point{public:Point(double i, double j) 下列程序的执行结果为【 】。include <iostream. h>class Point{public:Point(double i, double j) { x=i; y=j;}double Area() const { return 0.0;}private:double x, y;};class Rectangle: public Point{public:Rectangle(double i, double j, double k, double 1)double Area() const {return w * h;}private:double w, h;};Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).{w=k, h=1}void fun(Point s){cout<<s. Area()<<end1;}void main( ){Rectangle rec(3.0, 5.2, 15.0. 25.0);fun(rec)}

考题 阅读以下说明和JAVA 2代码,填入(n)处的。[说明]以下JAVA程序实现了在接口interface iShape2D的定义和应用,仔细阅读代码和相关注释,将程序补充完整。[代码6-1]interface iShape2D //定义接口{(1)(2)}(3)//实现CRectangle类{int width, height;(4) CRectangle (int w,int h) {width=w;height=h;}public void area ( ){ //定义area( )的处理方式System. out.println ("area="+width*height);}}(5)//实现CCircle类{double radius;(6) CCircle (double r) {radius=r;}public void area ( ) { //定义area( )的处理方式System.out.println ("area="+pi*radius*radius);}}[代码6-2]public class app10_4{public static void main(String args[]){CRectangle rect=new CRectangle (5,10);rect.area ( ); //调用CRectangle类里的area ( ) methodCCircle cir=new CCircle (2.0);cir.area ( ); //调用CCircl类里的area ( ) method}}

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】以下程序的功能是计算正方体、球体和圆柱体的表面积和体积并输出。程序由4个类组成:类cube、sphere和cylinder分别表示正方体、球体和圆柱体;抽象类 container为抽象类,提供了两个纯虚拟函数surface_area()和volum(),作为通用接口。【C++程序】include<iostream.h>define pi 3.1416class container{protected:double radius;public:container(double radius) {container::radius=radius;}virtual double surface_area()=0;virtual double velum()=0;};class cube:(1){ //定义正方体类public:cube(double radius):container(radius){};double surface_area () {return 6 * radius * radius;}double volum() {return radius * radius * radius;}};class sphere:(2){ //定义球体类public:sphere(double radius): container(radius){};double surface_area() { return (3);}double volum() {return pi * radius * radius * radius * 4/3;}};class cylinder:(4){ //定义圆柱体类double height;public:cylinder(double radius,double height):container(radius){container::height=height;}double surface_are a () { return 2 * pi * radius * (height+radius); }double volum () {return (5);}};void main(){container * p;cube obj1 (5);sphere obj2(5);cylinder obj3(5,5);p=obj1;cout<<“正方体表面积”(<<p->surface_area()<<end1;cont<<“正方体体积”<<p->volume()<<end1;p=obj2;cout<<“球体表面积”<<p->surface_area()<<end1;cout<<“球体体积”<<p->volume()<<end1;p=obj3;cout<<“球体表面积”<<p->surface_area()<<end1;cout<<“球体体积”<<p->volume()<<end1;}

考题 下列程序中,先声明一个圆类circle和一个桌子类table,另外声明一个圆桌类roundtable,它是由 circle和table两个类派生的,要求声明一个圆桌类对象,并输出圆桌的高度,面积和颜色。请填空完成程序include<iostream.h>include<string.h>class circle{double radius;public:circle(double r){radius=r;}double get_area(){return 3.416*radius*radius;}};class table{double height;public:table(double h)<height=h;}double get_height(){return height;}};class roundtable:public table,public circle{char *color;public:roundtable(double h,double r,char c[]): 【 】 {color=new char[strlen(c) +1];【 】;};char*get_color(){return color;}}:void main(){roundtable rt(0.8,1.0,“白色”);cout<<"圆桌的高:"<<rt. get_height()<<end1;cout<<"圆桌面积:"<<rt.get_area()<<end1;cout<<"圆桌颜色:"<<n.get color()<<end1;}

考题 阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。[说明]以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。[JAVA代码]//定义自己的异常类class CCircleException extends Exception{}// 定义类 CCircleclass 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( ) ;}}

考题 本题的功能是用文本框来设定表盘中指针的位置。窗口中有一个画板和两个文本框,画板中绘制了一个表盘和时针、分针,通过文本框分别设定“时”和“分”,表盘中的时针和分针就会指到对应的位置上。import java.awt.*;import java.awt.event*;import java.awt.geom.*;import javax.swing.*;import javax.swing.event.*;public class java3{public static void main(String[]args){TextTestFrame. frame=new TextTestFrame():frame.setDefauhCloseOperation(JFrame.EXIT_0N_CLOSE);frame.show();}}class TextTestFrame. extends JFrame{public TextTestFrame(){setTitle("java3"):setSize(DEFAULT_WIDTH,DEFAULT_HElGHT);Container contentPane=getContentPane();DocumentListener listener=new DoeumentListen-er();JPanel panel=new JPanel();hourField=new JTextField("12",3);panel.add(hourField);hourField.getDocument().addDocumentListener(this);minuteField=new JTextField("00",3):panel.add(minuteField);minuteField.getDocument().addDocumentListener(listener);contentPane.add(panel,BorderLayout.S()UTH);clock=new ClockPanel();contentPane.add(clock,BorderLayout.CEN-TER);}public void setClock(){try{int hours=Integer.parseInt(hourField.getText().trim()):int minutes=Integer.parseInt(minuteField.getText().trim());clock.setTime(hours,minutes);}catch(NumberFormatExcepfion e){}}public static final int DEFAULT_WIDTH=300;public static final int DEFAULT_HEIGHT=300;private J TextField hourField;private JTextField minuteField;private ClockPanel clock;private class clockFieldListener extends Docu-mentListener{public void insertUpdate(DocumentEvent e){ set-Clock();}public void removeUpdate(DocumentEvent e){setClock();}public void changedUpdate(DocumentEvent e){}}}class ClockPanel extends JPanel{pubhc void paintComponent(Graphics g){super.paintComponent(g);Graphies2D g2=(Graphics2D)g;Ellipse2D circle=new Ellipse2D.Double(0,0,2* RADIUS,2*RADIUS);g2.draw(circle);double hourAngle=Math.toRadians(90-360*minutes/(12*60));drawHand(92,hourAngle,HOUR_HAND_LENGTH);double minuteAngle=Math.toRadians(90-360*minutes/60);drawHand(g2,minuteAngle,MINUTE_HAND_LENGTH):}punic void drawHand(Graphics2D g2,double angle,double handLength){Point2D end=new Point2D.Double(RADIUS+handLength*Math.cos(angle),RADIUS-handLength*Math.sin(angle));Point2D center=new Point2D.Double(RADIUS,RADIUS):g2.draw(new Line2D.Double(center,end));}public void setTime(int h,int m){minutes=h*60+m;repaint();}private double minutes=0;private double RADIUS=100;private double MINUTE_HAND_LENGTH=0.8*RADIUS;private double HOUR_HAND_LENGTH=0.6*RADIUS:}

考题 阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。 【说明】 以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。 【Java代码】 interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}

考题 Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()A、 abstract public void methoda ();B、 public abstract double inethoda ();C、 static void methoda (double dl) {}D、 public native double methoda () {}E、 protected void methoda (double dl) {}

考题 1. class Super {  2. public float getNum() { return 3.0f; }  3. }  4.   5. public class Sub extends Super {  6.   7. }  Which method, placed at line6, causes compilation to fail?()  A、 public void getNum(){}B、 public void getNum(double d){}C、 public float getNum() { return 4.0f; }D、 public double getNum(float d) { return 4.0d; }

考题 class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()A、 Public float getNum() {return 4.0f; }B、 Public void getNum (){}C、 Public void getNum (double d){}D、 Public double getNum (float d) {retrun 4.0f; }

考题 public class OuterClass {   private double d1 1.0;   //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()A、 static class InnerOne {  public double methoda() {return d1;}  }B、 static class InnerOne {  static double methoda() {return d1;}  }C、 private class InnerOne {  public double methoda() {return d1;}  }D、 protected class InnerOne {  static double methoda() {return d1;}  }E、 public abstract class InnerOne {  public abstract double methoda();  }

考题 public class Mycircle {  public double radius;  public double diameter;  public void setRadius(double radius)  this.radius = radius;  this.diameter= radius * 2;  }  public double getRadius()   {  return radius;  }  Which statement is true?()  A、 The Mycircle class is fully encapsulated.B、 The diameter of a given MyCircle is guaranteed to be twice its radius.C、 Lines 6 and 7 should be in a synchronized block to ensure encapsulation.D、 The radius of a MyCircle object can be set without affecting its diameter.

考题 1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()  A、 static class InnerOne { public double methoda() { return d1; } }B、 static class InnerOne { static double methoda() { return d1; } }C、 private class InnerOne { public double methoda() { return d1; } }D、 protected class InnerOne { static double methoda() { return d1; } }E、 public abstract class InnerOne { public abstract double methoda(); }

考题 1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()  A、  Public float getNum()   {return 4.0f; }B、  Public void getNum ()  { }C、  Public void getNum (double d)   { }D、  Public double getNum (float d) {retrun 4.0f; }

考题 Which will declare a method that is available to all members of the same package and can be referenced without an instance of the class?()  A、 Abstract public void methoda();B、 Public abstract double methoda();C、 Static void methoda(double d1){}D、 Public native double methoda()  {}E、 Protected void methoda(double d1)  {}

考题 public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

考题 多选题public class OuterClass {  private double d1  1.0;  //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()Astatic class InnerOne {  public double methoda() {return d1;}  }Bstatic class InnerOne {  static double methoda() {return d1;} }Cprivate class InnerOne {  public double methoda() {return d1;} }Dprotected class InnerOne {  static double methoda() {return d1;} }Epublic abstract class InnerOne {  public abstract double methoda();  }

考题 单选题class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()A  Public float getNum() {return 4.0f; }B  Public void getNum (){}C  Public void getNum (double d){}D  Public double getNum (float d) {retrun 4.0f; }

考题 单选题1. class Super {  2. public float getNum() { return 3.0f; }  3. }  4.   5. public class Sub extends Super {  6.   7. }  Which method, placed at line6, causes compilation to fail?()A  public void getNum(){}B  public void getNum(double d){}C  public float getNum() { return 4.0f; }D  public double getNum(float d) { return 4.0d; }

考题 单选题public class Mycircle {  public double radius;  public double diameter;  public void setRadius(double radius)  this.radius = radius;  this.diameter= radius * 2;  }  public double getRadius()   {  return radius;  }  Which statement is true?()A  The Mycircle class is fully encapsulated.B  The diameter of a given MyCircle is guaranteed to be twice its radius.C  Lines 6 and 7 should be in a synchronized block to ensure encapsulation.D  The radius of a MyCircle object can be set without affecting its diameter.

考题 多选题1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()Astatic class InnerOne { public double methoda() { return d1; } }Bstatic class InnerOne { static double methoda() { return d1; } }Cprivate class InnerOne { public double methoda() { return d1; } }Dprotected class InnerOne { static double methoda() { return d1; } }Epublic abstract class InnerOne { public abstract double methoda(); }

考题 多选题public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

考题 单选题Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()A  abstract public void methoda ();B  public abstract double inethoda ();C  static void methoda (double dl) {}D  public native double methoda () {}E  protected void methoda (double dl) {}

考题 单选题Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()A  Abstract public void methoda();B  Public abstract double methoda();C  Static void methoda(double d1){}D  Public native double methoda(){}E  Protected void methoda(double d1){}

考题 单选题1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()A   Public float getNum()   {return 4.0f; }B   Public void getNum ()  { }C   Public void getNum (double d)   { }D   Public double getNum (float d) {retrun 4.0f; }