Given the following code what will be output? 这是题目!

解决方案 »

  1.   

    选3。
    j是static的,所以在任何地方对它的改变都是有效的。而i是int型,在作为方法的参数传递时,是按值传递的,在方法内对它的改变并不影响它的值。
      

  2.   

    基础知识果然了得!
    在发标!
    What will be the result when you try to compile and run the following code? 
    private class Base{
        Base(){
    int i = 100;
    System.out.println(i);
        }
    }public class Pri extends Base{
        static int i = 200;
        public static void main(String argv[]){
    Pri p = new Pri();
    System.out.println(i);
        }
    }
    1) Error at compile time 
    2) 200 
    3) 100 followed by 200 
    4) 100 
      

  3.   

    我试试,选2
    我是这样想的,虽然Pri 继承 Base,但变量i又重新被声明了一次。复会为200,下面就打印出200,在这期间Pri并没有调用父类Base,只是定义了一个P,而i的值没变还是200,因为i为静态。
      呵呵呵……不知道对不对,乱说的,不对还请高手指点指点
      

  4.   

    长见识了!base class must bu public
      

  5.   

    哈哈,我想,可能是因为只能有一个PUBLIC的原因吧
      

  6.   

    aben456(风轻扬)同志一刀将我斩于马下啊,我危难之机,用出我的杀手剑
    You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique. What interface might be most suitable to meet this need? 1)Set 
    2)List 
    3)Map 
    4)Vector 说出理由,并比较四者的异同什么时候采用那种更为合适???
      

  7.   

    3
    static int j=20;为类的变量,所以可以被改变
    i 为局部变量,或者叫方法变量;不能再方法之外被改变呢
    不知道对否/
      

  8.   

    基础知识果然了得!
    在发标!
    What will be the result when you try to compile and run the following code? 
    private class Base{
        Base(){
    int i = 100;
    System.out.println(i);
        }
    }public class Pri extends Base{
        static int i = 200;
        public static void main(String argv[]){
    Pri p = new Pri();
    System.out.println(i);
        }
    }
    1) Error at compile time 
    2) 200 
    3) 100 followed by 200 
    4) 100 应该是3‘
      

  9.   

    这个问题很简单大家侃侃!What will happen when you attempt to compile and run this code?private class Base{}
    public class Vis{
            transient int  iVal;
            public static void main(String elephant[]){
            }
    }1)Compile time error: Base cannot be private
    2)Compile time error indicating that an integer cannot be transient
    3)Compile time error transient not a data type
    4)Compile time error malformed main method说明理由!答对有分!
      

  10.   

    error!大哥想想再答,而且要说明理由,你好象在摸彩券啊!
      

  11.   

    这个问题很简单大家侃侃!What will happen when you attempt to compile and run this code?private class Base{}
    public class Vis{
            transient int  iVal;
            public static void main(String elephant[]){
            }
    }1)Compile time error: Base cannot be private
    2)Compile time error indicating that an integer cannot be transient
    3)Compile time error transient not a data type
    4)Compile time error malformed main method说明理由!答对有分!
    ------------------1         第一个类不可以是private
      

  12.   

    1;ERROR:modifier private not allowed here?
    我也不知道什么意思
      

  13.   

    : qxjavajava(射手座) 
    难道把第一个类放到后面去就可以了吗?
    结果还是一样的错误:modifier private not allowed here
      

  14.   

    对不起我写错了,Top-level class may not be declared private ,
    所以用并列关系写一个private 显然是wrong 
     public class  qqq
    {
    public static void main(String[] args) 
    {
    System.out.println("Hello World!");
    } private class prpr
    {
    public void  writerS()
    {
    System.out.println("****");
    }
    }
    }
    ----------this is OK
      

  15.   

    这位搂主是拿scjp的题来烤大家。
      

  16.   

    private 的类应该定义在public 类的内部,这样才能标名是谁的private类
      

  17.   

    最高阶层(top-level)是什么意思,谁放在上面谁就是最高吗???
    mem_fox(JAVA狐狸) 的解释比较合理
      

  18.   

    无论什么问题,只要一讨论打家都会有进步!
    For a class defined inside a method, what rule governs access to the variables of the enclosing method?1) The class can access any variable
    2) The class can only access static variables
    3) The class can only access transient variables
    4) The class can only access final variables请分别区分static variables,transient variables,final ariables各个变量的作用范围
      

  19.   

    这是java的基础知识,有兴趣讨论一下!
      

  20.   

    private class Base{
        Base(){
    int i = 100;
    System.out.println(i);
        }
    }public class Pri extends Base{
        static int i = 200;
        public static void main(String argv[]){
    Pri p = new Pri();
    System.out.println(i);
        }
    }
    1) Error at compile time 
    2) 200 
    3) 100 followed by 200 
    4) 100 
    究竟这个问题答案是不是3啊??
    new一个 Pri时Base打印100。再打印Pri本身的200,我认为时这样
      

  21.   

    compile error!!!class 的所谓 modifier 只有 public, abstract, final,( default);
    可没有什么private,protected,static这些东西;
    而类的成员可以声明为:private,protected,public;
    其中,成员变量又可以声明为:static,final,transient,volatile;
    成员方法可以声明为:static,abstract,final,sychronized,native;