首页题目详情

读程序,写出正确的运行结果。(5分)

class A{ 

class Dog{ 

  private String name; 

  private int age; 

  public int step; 

  Dog(String s,int a) {

    name=s;

    age=a;

    step=0;

  }

  public void run(Dog fast) {

    fast.step++;

  }

}

public static void main (String args[]){

  A a=new A(); 

  Dog d=a.new Dog("Tom",3);

  d.step=25; 

  d.run(d); 

  System.out.println(d.step); 

问答题
2023-10-07 11:40:19
0 20
参考答案:2...
查看答案
 参考答案
科目:Java程序设计
学科:公安学
感兴趣题目
读程序,写出正确的运行结果。public class Example{   String str=new String("good");   char[]ch={'a','b','c'};   public static void main(String args[]){     Example ex=new Example();     ex.change(ex.str,ex.ch);     System.out.print(ex.str+" and ");     System.out.print(ex.ch);   }   public void change(String str,char ch[]){     str="test ok";     ch[0]='g';   } }
读程序,写出正确的运行结果。class Test extends Thread{     public void run(){         System.out.println("1");         yield();         System.out.println("2");         suspend();         System.out.println("3");         resume();         System.out.println("4");     }     public static void main(String []args){         Test t = new Test();         t.start();}}
阅读下列代码,写出运行结果。class Instrument {  public void play() {    System.out.println("Instrument.play()");  }}class Wind  extends  Instrument {  public void play() {    System.out.println("Wind.play()");  }}public class Music {  public static void tune(Instrument  k ) {    k.play();  }  public static void main(String[] args) {    Wind flute = new Wind();    tune(flute);   }}
下面的代码执行结果是什么? class Aclass{    void go(){     System.out.println("Aclass");   }   }   public class Bclass extends Aclass{    void go(){     System.out.println("Bclass");    }   public static void main(String args[]){    Aclass a=new Aclass();    Aclass a1=new Bclass();     a.go();     a1.go();   }}
下列程序编译运行后输出什么?public class Arrays {  public static void main(String[] args) {    int[] a1 = { 1, 2, 3, 4, 5 };    int[] a2;    a2 = a1;    for(int i = 0; i < a2.length; i++)      a2[i]++;    for(int i = 0; i < a1.length; i++)      prt("a1[" + i + "] = " + a1[i]);  }  static void prt(String s) {    System.out.println(s);  }} 
绘图铅笔铅芯的软硬用字母“B”和“H”表示。B前的数值越大,表示铅芯()
已知A点距H、V、W面的距离分别为20、20、20;B点在A点上方5,右方10,后方10,因此可知B的坐标为( )。
已知点A(20,8,8),与点A对称于W面的点B的坐标值是( )。
若曲线上所有的点都在同一平面内,称为平面曲线。以下选项中,属于平面曲线的有( )。
平面与圆球面相交,其截交线是( )。
齿轮模数m= 2p/3.14 。
工程图样尺寸注法的基本规定中,以下描述正确的是( )。