整专业资料
微信QQ群
考生网QQ群

群号:517231281

扫码加群
点击二维码加群

考生网微信公众号

微信号:zikaosw

课程试听
最新资讯

手机端访问

1、直接输入www.zikaosw.cn
2、扫描左侧二维码

登录 | 注册
登录/注册后,可享受
  • 课程免费试听
  • 试做在线题库
  • 学习提升指导
  • [主观题] 【简答题】阅读下面程序,如果在横线上分别填写①i=m②i=b③i=p.a④i=p.change(100)四个赋值语句,有哪些不合法?请写出原因。
    class  Class2201
    {
    private  int  a;
    public  int  change(int  m){return  m;}
    }
    public  class  Class22  extends  Person
    {
    public  int  b;
    public  static  void  main(String[]args)
    {
    Class2201  p=new  Class2201();
    Class22    t=new  Class22();
    int  i;
    ___;
    }
    }
     

     纠错    

  • 助考班推荐

您可能感兴趣的试题

  • 1、[单选题]在Java语言中,一般不作为容器使用的是()

    • A、JDialog
    • B、JFrame
    • C、JTextArea
    • D、JPanel
  • 2、[填空题]第1题 在  Java  中所有实现的多维数组,实际上是由一维数组构成的______。
     

  • 3、[主观题]【程序分析题】阅读程序,画出程序运行后的界面并写出程序的功能。
    import  java.awt.*;
    import  javax.swing.*;
    import  java.awt.event.*;
    public  class  Class3601  implements  AdjustmentListener
    {
    JScrollBar  myBar;
    JLabel  label;
    public  Class3601(String  s)
    {
    JFrame  myWin=new  JFrame(s);
    Container  con=myWin.getContentPane();
    con.setLayout(new  GridLayout(2,1));
    myBar=new  JScrollBar(JScrollBar.HORIZONTAL,5,20,0,300);
    label=new  JLabel(""+myBar.getValue(),JLabel.CENTER);
    myBar.addAdjustmentListener(this);
    con.add(label);
    con.add(myBar);
    myWin.setSize(300,100);
    myWin.setVisible(true);
    }
    public  void  adjustmentValueChanged(AdjustmentEvent  e)
    {
    label.setText(""+e.getAdjustable().getValue());
    }
    public  static  void  main(String[]  args)
    {
    new  Class3601("Class3601");
    }
    }
     

  • 4、[主观题]【程序填空题】方法f2702(int  n)返回2~n之间的所有质数的个数。
    int    f2702(int  n)
    {
    int  i,j,count=0;
    for(i=2;i<=n;i++)
    {
    for(j=2;jif  (i%j==0)___
    if(j==i)___;
    }
    return  count;
    }
     

  • 5、[主观题]【程序分析题】阅读下面程序,写出程序功能。
    import  java.applet.*;import  java.awt.*;
    public  class  Class3602  extends  Applet  implements  Runnable
    {
    Thread  redBall,blueBall;Graphics  redPen,bluePen;
    int  blueSeta=0,redSeta=0;
    public  void  init()
    {
    setSize(250,200);
    redBall=new  Thread(this);blueBall=new  Thread(this);
    redPen=getGraphics();bluePen=getGraphics();
    redPen.setColor(Color.red);bluePen.setColor(Color.blue);
    setBackground(Color.gray);
    }
    public  void  start()
    {
    redBall.start();blueBall.start();
    }
    public  void  run()
    {
    int  x,y;
    while(true)
    {
    if(Thread.currentThread()==redBall)
    {
    x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));
    y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));
    redPen.setColor(Color.gray);
    redPen.fillOval(100+x,100+y,10,10);
    redSeta  +=3;
    if(redSeta>=360)  redSeta=0;
    x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));
    y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));
    redPen.setColor(Color.red);
    redPen.fillOval(100+x,100+y,10,10);
    try  {redBall.sleep(20);}
    catch(InterruptedException  e){}
    }
    else  if  (Thread.currentThread()==blueBall)
    {
    x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));
    y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));
    bluePen.setColor(Color.gray);
    bluePen.fillOval(150+x,100+y,10,10);
    blueSeta-=3;
    if(blueSeta<=-360)  blueSeta=0;
    x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));
    y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));
    bluePen.setColor(Color.blue);
    bluePen.fillOval(150+x,100+y,10,10);
    try  {blueBall.sleep(40);}
    catch(InterruptedException  e){}
    }
    }
    }
    }
     

Copyright © 2010 - 2023 湖南求实创新教育科技有限公司 All Right Reserved.

温馨提示:如您需要的资料本网暂时没有,请于工作日08:00-18:00,点击这里,联系客服及时补充资料。