首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

几道java程序的题目,

2012-01-15 
几道java程序的题目,在线等。。。Question1classJMM119{publicstaticvoidmain(String[]args){inti0,j9l1:d

几道java程序的题目,在线等。。。
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   above

Question     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   above

Question     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   above

Question     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   above

Question     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;}


[解决办法]
不知道你想问什么 帮你顶
[解决办法]
相当没意思的题目

你运行一下, 然后理解理解, 有什么理解不了的, 再提出来行不?
------解决方案--------------------


$ zz╭ ⺌╮╭ ﹌╮. $
$ z(o-.-o)(o-.-o) . $
$ ┏~﹊︸ ̄~﹊︸ ̄~┓ $
$ IT者-IT开发者的网站-- $
$ 10万篇技术资料--天天更新 $
$ -----www.itzhe.cn----- $
[解决办法]
你的第一个就出现了问题,if 语句里 是不能作break语句的,我觉得是结果是H
[解决办法]
1.8,4
2.Compile-time error at 3
3.0null
4.Bird,Bird
5.ACD
这是我的答案
[解决办法]
做JAVA 连开发环境都没?
[解决办法]
正确答案是:1 F 2 D 3 C 4 C 5 A C D
不过楼主仿佛发错位置了,这个应该是SCJP的题目吧
以上答案有什么问题的欢迎提出
[解决办法]
1.8,4
2.Compile-time error at 3
3.0null
4.Bird,Bird
5.ACD
我选的答案,不过第四个我运行了一下,确实如luoyinghua(大拇指) 说的,是Bird,Cat
[解决办法]
en,xuexi...
[解决办法]
能不能给讲一下第三题,谢谢 大家了
[解决办法]
它们默认值在内存中是每一位都是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进行字符串的拼接。

[解决办法]
上机运行~
[解决办法]
这里有解决的办法啊?http://www.javadingle.com
[解决办法]
呵呵,我虚心学习
[解决办法]
是csjp的题目

[解决办法]

[解决办法]
晕啊 找本书看看java基础
[解决办法]
1 F 2 D 3 C 4 C 5 A C D
[解决办法]
呵呵,有些基础是该好好学学了
[解决办法]
运行测试一下就可以了
[解决办法]
不是这样说的哦,要是去公司面试 人家不给你IDE你拿什么测试?
[解决办法]
虚心学习!..........
[解决办法]
enen
[解决办法]
呵,上面的一个朋友连Java环境都没有哦。我晕倒
[解决办法]
我虚心学习哦

热点排行
Bad Request.