单选题现有:  class Passer f  static final int X=5;  public  static void main (String  []  args)  {      new  Passer().go (x);      System. out .print (x);      }  void go (int x)  {     System. out .print(x++);     }     结果是什么?()A 55B 56C 65D 66

题目
单选题
现有:  class Passer f  static final int X=5;  public  static void main (String  []  args)  {      new  Passer().go (x);      System. out .print (x);      }  void go (int x)  {     System. out .print(x++);     }     结果是什么?()
A

55

B

56

C

65

D

66


相似考题
参考答案和解析
正确答案: A
解析: 暂无解析
更多“现有:  class Passer f  static final int X=5;  public  static v”相关问题
  • 第1题:

    请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。

    [题目要求]

    生成下面左边图形界面,单击图中的New按钮,弹出如右图所示的对话框。

    源程序:

    import java.awt.*;

    import java.awt.event.*;

    import javax.swing.*;

    public class Java_3 {

    public static void main(String[] args) {

    MulticastFrame. frame=new MulticastFrame();

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.show();

    }

    }

    class MulticastFrame. extends JFrame. {

    public MulticastFrame() {

    setTitle("MulticastTest");

    setSize(WIDTH,HEIGHT);

    MulticastPanel panel=new MulticastPanel();

    Container contentPane=getContentPane();

    contentPane.add( (1) );

    }

    public static final int WIDTH=300;

    public static final int HEIGHT=200;

    }

    class MulticastPanel extends JPanel }

    public MulticastPanel() {

    JButton newButton=new JButton("New");

    add(newButton);

    ActionListener newListener=new ActionListener() {

    public void actionPerformed(ActionEvent event) {

    makeNewFrame();

    }

    };

    newButton.addActionListener(newListener);

    closeAllButton=new JButton("Close all");

    add(closeAllButton);

    }

    private void makeNewFrame() {

    final BlankFrame. frame=new BlankFrame();

    frame.show();

    ActionListener closeAllListener=new ActionListener() {

    public void actionPerformed(ActionEvent event) {

    frame. (2) (); //使窗口隐藏或消除

    }

    };

    closeAllButton.addActionListener( (3) );

    }

    private JButton closeAllButton;

    }

    Class BlankFrame. extends JFrame. {

    public BlankFrame() {

    (4) ++;

    setTitle("Frame"+counter);

    setSize(WIDTH,HEIGHT);

    setLocation(SPACING*counter,SPACING*counter);

    }

    public static final int WIDTH=200;

    public static final int HEIGHT=150;

    public static final int SPACING=30;

    private static int counter=0;

    }


    正确答案:panel hide closeAllListener counter
    panel hide closeAllListener counter 解析: 通过下面的程序可以看出新的窗口的标题为Frame和数字,数字是自增的,所以自增的变量名称为counter。
    [程序解析] 程序在窗口中用按钮新建窗口,并且可以通过按钮关闭窗口。本程序采用的是swing类,Swing构件和AWT构件不同,Swing构件不能直接添加到顶层容器中,它必须添加到一个Swing顶层容器相关联的内容面板上。对JFrame添加构件有两种方式:①用getContentPane()方法获得JFrame的内容面板,再对其加入构件,Java上机考试中经常采用这种方式,而且也是一个考点。本程序就是采用的这种方法。②建立一个JPanel或JDesktopPane之类的中间容器,把构件添加到容器中,再用setContentPane()方法把该容器置为JFrame的内容面板。

  • 第2题:

    下列哪个成员方法声明是正确的? ( )

    A.public abstract final int f(){...}

    B.public static boolean f(){...}

    C.static protected void g(a,{...}

    D.protected private number;


    正确答案:B
    解析:本题考查对成员方法声明的掌握程度。选项A错误,成员变量不能同时声明成abstract和final;选项B正确,声明了一个公有静态返回值类型是布尔类型的方法f();选项C错误,protected应在static之前;选项D错误,既不是方法声明,也不是正确的成员变量声明。

  • 第3题:

    现有:   class TestMain {      static int x = 2;  static { x = 4; }   static public void main(String[] args) {    int y = x + 1;   System.out.println(y);    }    }    和命令行:  java TestMain    结果为:() 

    • A、 3
    • B、 5
    • C、 编译失败
    • D、 运行时异常被抛出

    正确答案:B

  • 第4题:

    现有: 1.class Passer f 2.static final int X=5; 3.public static void main (String [] args) { 4.new Passer( ).go (x); 5.System. out .print (x); 6. ) 7.void go (int x) { 8.System. out .print(x++); 9.} 10.}结果是什么?()

    • A、55
    • B、56
    • C、65
    • D、66

    正确答案:A

  • 第5题:

    class Passer {  static final int x = 5;  public static void main(String [] args) { new Passer().go(x);  System.out.print(x);  }  void go(int x) {  System.out.print(++x);  }  }  结果是什么?() 

    • A、55
    • B、56
    • C、65
    • D、66

    正确答案:C

  • 第6题:

    现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()     

    • A、1
    • B、2
    • C、3
    • D、编译失败

    正确答案:D

  • 第7题:

    单选题
    现有:  class Top  {     static int X=l;  public Top()  {  x*=3; }     }  class Middle extends Top  {      public  Middle()    {x+=l;  }  public static void main(String  []  args)  {     Middle m=new Middle();    System.out.println (x);    }     }  结果是什么?()
    A

      2

    B

      3

    C

      4

    D

    编译失败


    正确答案: A
    解析: 暂无解析

  • 第8题:

    单选题
    1. class Passer2 {   2. //insert code here   3. static int bigState = 42;   4. public static void main(String [] args) {   5. bigState = p2.go(bigState);   6. System.out.print(bigState);   7. }   8. int go(int x) {   9. return ++x;   10. }   11. }  和4段代码片段:  static Passer2 p2 = new Passer2();  final static Passer2 p2 = new Passer2();  private static Passer2 p2 = new Passer2();  final private static Passer2 p2 = new Passer2();  有多少行分别插入到第2行,可以编译?()
    A

    0

    B

    1

    C

    3

    D

    4


    正确答案: C
    解析: 暂无解析

  • 第9题:

    单选题
    interface DeclareStuff{  public static final int EASY = 3;  void doStuff(int t); }  public class TestDeclare implements DeclareStuff {  public static void main(String [] args) {  int x=5;  new TestDeclare().doStuff(++x);  }  void doStuff(int s) {  s += EASY + ++s;  System.out.println(”s “ + s);  }  }  What is the result?()
    A

     s 14

    B

     s 16

    C

     s 10

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第10题:

    单选题
    现有:   class TestMain {      static int x = 2;  static { x = 4; }   static public void main(String[] args) {    int y = x + 1;   System.out.println(y);    }    }    和命令行:  java TestMain    结果为:()
    A

     3

    B

     5

    C

     编译失败

    D

     运行时异常被抛出


    正确答案: B
    解析: 暂无解析

  • 第11题:

    单选题
    现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()
    A

    1

    B

    2

    C

    3

    D

    编译失败


    正确答案: B
    解析: 暂无解析

  • 第12题:

    单选题
    现有:  class Banana2  f      static int X=2;  public static void main (String  []  args)  {     int X=2;   Banana2 b=new Banana2();     b.go(x);     }  static  {x+=x; }   void go (int x)  {    ++x;  System. out.println (x);    }         结果为:()
    A

    7

    B

    5

    C

    3

    D

    2


    正确答案: B
    解析: 暂无解析

  • 第13题:

    下面的例子中

    using System;

    class A

    {

    public static int X;

    static A(){

    X=B.Y+1;

    }

    }

    class B

    {

    public static int Y=A.X+1;

    static B(){}

    static void Main(){

    Console.WriteLine("X={0},Y={1}",A.X,B.Y);

    }

    }

    产生的输出结果是什么?


    正确答案:
    答:x=1,y=2

  • 第14题:

    下列哪个成员方法声明是正确的? ( )

    A.public abstract final int f(){…}

    B.public static boolean f(){…}

    C.static protected void g(a,b){…}

    D.protected private number;


    正确答案:B
    解析:本题考查对成员方法声明的掌握程度。选项A错误,成员变量不能同时声明成abstract 和 final;选项B正确,声明了一个公有静态返回值类型是布尔类型的方法 f();选项C错误,protected应在static之前;选项D错误,既不是方法声明,也不是正确的成员变量声明。

  • 第15题:

    interface DeclareStuff{  public static final int EASY = 3;  void doStuff(int t); }  public class TestDeclare implements DeclareStuff {  public static void main(String [] args) {  int x=5;  new TestDeclare().doStuff(++x);  }  void doStuff(int s) {  s += EASY + ++s;  System.out.println(”s “ + s);  }  }  What is the result?() 

    • A、 s 14
    • B、 s 16
    • C、 s 10
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第16题:

    class Top {  static int x = 1;  public Top(int y) { x *= 3; }  }  class Middle extends Top {  public Middle() { x += 1; }  public static void main(String [] args) {  Middle m = new Middle();  System.out.println(x);  }  }  结果为:() 

    • A、1
    • B、2
    • C、3
    • D、编译失败

    正确答案:D

  • 第17题:

    Which three form part of correct array declarations?()  

    • A、 public int a []
    • B、 static int [] a
    • C、 public [] int a
    • D、 private int a [3]
    • E、 private int [3] a []
    • F、 public final int [] a

    正确答案:A,B,F

  • 第18题:

    Which three statements are true?()

    • A、A final method in class X can be abstract if and only if X is abstract.
    • B、A protected method in class X can be overridden by any subclass of X.
    • C、A private static method can be called only within other static methods in class X.
    • D、A non-static public final method in class X can be overridden in any subclass of X.
    • E、A public static method in class X can be called by a subclass of X without explicitly referencing the class X.
    • F、A method with the same signature as a private final method in class X can be implemented in a subclass of X.
    • G、A protected method in class X can be overridden by a subclass of X only if the subclass is in the same package as X.

    正确答案:B,E,F

  • 第19题:

    单选题
    现有:   class TestMain {       static int x = 2;    static { x = 4; }   public static void main(String... args) {     int y = x + 1;   System.out.println(y);   }   }    和命令行:  java TestMain    结果为:()
    A

     3

    B

     5

    C

     编译失败

    D

     运行时异常被抛出


    正确答案: A
    解析: 暂无解析

  • 第20题:

    多选题
    Which three statements are true?()
    A

    A final method in class X can be abstract if and only if X is abstract.

    B

    A protected method in class X can be overridden by any subclass of X.

    C

    A private static method can be called only within other static methods in class X.

    D

    A non-static public final method in class X can be overridden in any subclass of X.

    E

    A public static method in class X can be called by a subclass of X without explicitly referencing the class X.

    F

    A method with the same signature as a private final method in class X can be implemented in a subclass of X.

    G

    A protected method in class X can be overridden by a subclass of X only if the subclass is in the same package as X.


    正确答案: D,G
    解析: 暂无解析

  • 第21题:

    单选题
    现有:  class Passer f  static final int X=5;  public  static void main (String  []  args)  {      new  Passer().go (x);      System. out .print (x);      }  void go (int x)  {     System. out .print(x++);     }     结果是什么?()
    A

    55

    B

    56

    C

    65

    D

    66


    正确答案: C
    解析: 暂无解析

  • 第22题:

    单选题
    class Passer {  static final int x = 5;  public static void main(String [] args) { new Passer().go(x);  System.out.print(x);  }  void go(int x) {  System.out.print(++x);  }  }  结果是什么?()
    A

    55

    B

    56

    C

    65

    D

    66


    正确答案: A
    解析: 暂无解析

  • 第23题:

    多选题
    现有:  public  class  TestDemo{     private int X-2;      static int y=3;  public  void method(){      final int i=100;      int j  =10;     class Cinner {  public void mymethod(){      //Here     }     }     }     } 在Here处可以访问的变量是哪些?()
    A

    X

    B

    y

    C

    j

    D

    i


    正确答案: A,C
    解析: 暂无解析

  • 第24题:

    多选题
    public class TestDemo{   private int x = 2;   static int y = 3;   public void method(){   final int i=100;   int j = 10;   class Cinner{   public void mymethod(){  //Here  }  }  }  }   在Here处可以访问的变量是哪些?()
    A

    x

    B

    y

    C

    i

    D

    j


    正确答案: D,A
    解析: 暂无解析