JAV A 面向对象基础测试题 提示:本题为第一阶段,JAVA 面向对象基础部分练习题,包括对象,类,继承,封装,多态,接口,内部类等等,java 核心基础,适合初学者对面向对象基础的知识进行测试,以便查漏补缺。 1. 程序执行的结果是:()。 01 public class Point{ 02 int y = 7; 03 public void step(int y) { 04 y += y; 05 System.out.println(y); 06 } 07 public static void main(String[] args) { 08 Point p = new Point(); 09 p.step(10); 10 } 11 } A.14 B.20 C.10 D.17 正确答案:B 解析: 2. 程序的执行结果是:()。 01 public class Question { 02 private int num; 03 public static void main(String [] args){ 04 Question q = new Question(); 05 q.num=13; 06 update(q); 07 System.out.println(q.num); 08 } 09 public static void update(Question q){ 10 q.num=9; 11 } 12 } A.13 B.9 C.0 D.4 正确答案:B 解析: 3. 程序执行的结果是:()。 01 public class Answer { 02 public static void main(String[] args) { 03 int score = 20; 04 Answer ans= new Answer(); 05 ans.add(score); 06 System.out.println(" main: score = " + score); 07 } 08 void add(int score) { 09 System.out.println(" add: score=" + score++); 10 } 11 } A. 1 add: score=21 2 main: score = 21 B. 1 add: score=20 2 main: score = 21 C. 1 add: score=21 2 main: score = 20 D. 1 add: score=20 2 main: score = 20 正确答案:D 解析: 4. 下列代码编译或运行的结果是:()。 01 public class Snow{ 02 public String jump(int x, int y) { 03 return "jump one"; 04 } 05 public String jump(int[] vals) { 06 return "jump two"; 07 } 08 public static void main(String[] args) { 09 Snow s=new Snow(); 10 System.out.println(s.jump(4, 5)); 11 } 12 } A.public String jump(int[] vals) {行,编译出错 B.System.out.println(s.jump(4, 5));行,抛出运行时异常 C.输出:jump one D.输出:jump two 正确答案:C 解析: 5. 关于下列代码说法正...