Question  1
class JMM119 {
    public static void main (String[] args) {
        int i = 0, j = 9;
        l1:
        do {
            l2:
          if (j < 4) {
              break l2;
          } else if (j-- < 7) {continue;}
          
          i++;
        } while (i++ < 7);
        System.out.print(i + "," + j);
    }
}
What is the result of attempting to compile and run the program? 
a.  Prints: 4,7 
b.  Prints: 6,6 
c.  Prints: 6,5 
d.  Prints: 6,4 
e.  Prints: 7,5 
f.  Prints: 8,4 
g.  Run-time error 
h.  Compile-time error 
i.  None of the aboveQuestion  2
package com.dan.chisholm;
public class A {
  public void m1() {System.out.print("A.m1, ");}
  protected void m2() {System.out.print("A.m2, ");}
  private void m3() {System.out.print("A.m3, ");}
  void m4() {System.out.print("A.m4, ");}
}  
class B {
  public static void main(String[] args) {
    A a = new A();
    a.m1();  // 1
    a.m2();  // 2
    a.m3();  // 3
    a.m4();  // 4
}}
Assume that the code appears in a single file named A.java. What is the result of attempting to compile and run the program? 
a.  Prints: A.m1, A.m2, A.m3, A.m4,  
b.  Compile-time error at 1. 
c.  Compile-time error at 2. 
d.  Compile-time error at 3. 
e.  Compile-time error at 4. 
f. None of the aboveQuestion  3
class GFM13 {
  static byte a; static short b; static char c;
  static int d; static long e; static String s;
  public static void main(String[] args) {
    System.out.println(a+b+c+d+e+s);
}}
What is the result of attempting to compile and run the program? 
a.  Prints: 00000null 
b.  Prints: 00000 
c.  Prints: 0null 
d.  Prints: 0 
e.  Prints: null 
f.  Compile-time error 
g.  Run-time error 
g. None of the aboveQuestion  4
class GFC301 {
  private String name;
  public GFC301(String name) {this.name = name;}
  public void setName(String name) {this.name = name;}
  public String getName() {return name;}
  public static void m1(GFC301 r1, GFC301 r2) {
    r1.setName("Bird");
    r2 = r1;
  }
  public static void main (String[] args) {
    GFC301 pet1 = new GFC301("Dog");
    GFC301 pet2 = new GFC301("Cat");
    m1(pet1,pet2);
    System.out.println(pet1.getName() + "," + pet2.getName());
}}
What is the result of attempting to compile and run the program? 
a.  Prints: Dog,Cat 
b.  Prints: Dog,Bird 
c.  Prints: Bird,Cat 
d.  Prints: Bird,Bird 
e.  Run-time error 
f.  Compile-time error 
h. None of the aboveQuestion  5
public class MethodOver{ 
   public void setVar(int a, int b, float c){} 
   } 
}
  which overload the setVar? (Please choice three)
  A.private void setVar(int a, float c, int b){} 
  B.protected void setVar(int a, int b, float c){} 
  C.public int setVar(int a, float c, int b){return a;} 
  D.public int setVar(int a, float c){return a;}

解决方案 »

  1.   

    $ zz╭ ╮╭ ﹌╮.       $
    $   z(o-.-o)(o-.-o) .      $
    $ ┏~﹊︸ ̄~﹊︸ ̄~┓      $
    $ IT者-IT开发者的网站--    $
    $ 10万篇技术资料--天天更新 $
    $ -----www.itzhe.cn-----   $
      

  2.   

    你的第一个就出现了问题,if 语句里 是不能作break语句的,我觉得是结果是H
      

  3.   

    1.8,4
    2.Compile-time error at 3
    3.0null
    4.Bird,Bird 
    5.ACD
    这是我的答案
      

  4.   

    运行了一下,第4个了,Bird,Cat 
      

  5.   

    正确答案是:1 F   2 D    3 C   4 C    5 A C D
    不过楼主仿佛发错位置了,这个应该是SCJP的题目吧
    以上答案有什么问题的欢迎提出
      

  6.   

    1.8,4
    2.Compile-time error at 3
    3.0null
    4.Bird,Bird 
    5.ACD
    我选的答案,不过第四个我运行了一下,确实如luoyinghua(大拇指) 说的,是Bird,Cat
      

  7.   

    BeenZ(妖) ( ) ,麻烦你,第四题,能否讲解一下?
      

  8.   

    呵呵,刚重新看了一下第四题,懂了。
    r2 = r1;这一步对pet1,pet2没影响
    就算pet1,r1,r2都指同一个对象,但pet还是指另外一个
      

  9.   

    首先,在m1方法中的r1.setName("Bird"); 将r1附值Bird;所以输出Bird,
    不过第2句 r2 = r1;  这里改变的是r2的引用的一个副本,而r2本身的值是不变的,所以还是cat
      

  10.   

    它们默认值在内存中是每一位都是0。
    所以
    static byte a;
        static short b;
        static char c;
        static int d;
        static long e;
    它们默认值就是0了
    static String s;就是null了。a + b + c + d + e是把较小的类型转换成较大的来进行加减。
    最后一个+s,就是把前面得到的long型数字,转换成String进行字符串的拼接。
      

  11.   

    这里有解决的办法啊?http://www.javadingle.com
      

  12.   

    等会回来我也上机试试,现在基础越来越差
    搂住,不介意我把这几个题目收到blog里面吧
      

  13.   

    你的第一个就出现了问题,if 语句里 是不能作break语句的,我觉得是结果是H
    =========================================
    不知道谁规定,if里面不能break;
    他break的是do while 循环
      

  14.   

    1 F   2 D    3 C   4 C    5 A C D
      

  15.   

    不是这样说的哦,要是去公司面试 人家不给你IDE你拿什么测试?
      

  16.   

    呵,上面的一个朋友连Java环境都没有哦。我晕倒