2017年最新java面试题及答案

2017-02-17 00:00:00小静 JAVA认证

  class B {

  private int radius = 10;

  public void draw() {

  System.out.println(“B.draw(), radius = ” + radius);

  }

  public B() {

  System.out.println(“B constructor”);

  draw();

  }

  }

  public class A extends B {

  private int radius = 1;

  public void draw() {

  System.out.println(“A.draw(), radius = ” + radius);

  }

  public A(int radius) {

  this.radius = radius;

  System.out.println(“A constructor”);

  }

  public static void main(String[] args) {

  A a = new A(5);

  }

  }

  3、写出下列程序运行结果。

  public class Test {

  static Test st=new Test();

  static int x ;

  static int y=0 ;

  public Test(){

  x++;

  y++;

  }

  public Test(int x,int y){

  this.x=x;

  this.y=y;

  }

  public static Test getInstance(){ return st ;}

  static{

  int i=0;

  System.out.println(“i=”+i);

  }

  void test() {

  Inner inner2 = new Inner2();

  inner2.display();

  }

  public static void main(String[] args) {

  Test test1=Test.getInstance();

  test1.test();

  System.out.println(“test1:x=” + test1.x+”;y=”+test1.y);

[JAVA认证]相关推荐

[JAVA认证]相关栏目推荐
查看更多
上一篇:Java学习如何走出第一步 下一篇:java程序员认证考试试题