程序分析题目

程序分析题目,第1张

1.

输出:0(int不初始化默认是0)

package bgc

public class Happy {

public static void main (String[] args){

int index=1

int a[]=new int[3]

int bas=a[index]

int baz=bas+index

System.out.println(a[baz])

}

}

2.

输出:i=0j=-1

public class ForLoop {

public static void main (String[] args){

int i=0,j=5

st:for(i++){

for(j--){

if(i>j) break st

}

}

System.out.println("i="+i+"j="+j)

}

}

3.

输出:t equals4

package bgc

public class Testt {

public static void main (String[] args){

int m=2,p=1,t=0

for(p<5p++){

if(t++>m){

m=p+t

}

}

System.out.println("t equals"+t)

}

}

4

解释下面的程序运行结果输出为什么是null

答案:public void My()不是构造函数,要改成Public My(),否则s不能初始化

public class My{

String s

public void My(){

s="Constructor"

}

public void go(){

System.out.println(s)}

public static void main(String args[]){

My m=new My()

m.go()}

}

5.

输出:无

Object 类的 equals 方法实现对象上差别可能性最大的相等关系;即,对于任何非空引用值 x 和 y,当且仅当 x 和 y 引用同一个对象时,此方法才返回 true(x == y 具有值 true)。

public class ThisClass {

public static void main (String[] args){

Object o=(Object)new ThisClass()

Object s=new Object()

if(o.equals(s))

System.out.println("true")

}

}

6.

public class C1 {

static int j=0

public void method(int a){

j++

}

}

class Test extends C1{

public int method(){

return j++

}

public void result(){

method(j)

System.out.println(j+method())

}

public static void main(String args[]){

new Test().result()

}

}

7.

class ThisClass{

static void foo() throws Exception{

throw new Exception()

}

public static void main(String args[]){

try{

foo()

}catch(Exception){

System.exit(0)

}

finally{

System.out.println("In finally")

}

}

}

二、下面编译可能有错 若有 为什么?

1.

为什么不能编译下面代码?

public class Test{

static int sn

int n

final static int fsn

final int fn}

2.

interface Action{

int i=10

}

class Happy implements Action{

public static void main(String args[]){

Happy h=new Happy()

int j

j=Action.i

j=Happy.i

j=h.i

}

}

编译运行的结果是什么?

三、注释处(catch?),应该放什么内容

答案:catch(EOFException e)

class Excep{

static void method() throws Exception{

throw new EOFException()

}

public static void main(String args[]){

try{

method()

}catch(////){

}

}

}

有几个没答。你最好在Eclipse里试一试,其实不费时间

A审计计划阶段

注册会计师在审计计划阶段执行分析程序,查找潜在风险领域,从而使审计更具效率和效果。

在审计的计划阶段,利用审计风险模型确定某项认定的计划检查风险,所使用的控制风险是审计 人员的计划估计水平。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8055966.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-13
下一篇2023-04-13

发表评论

登录后才能评论

评论列表(0条)

    保存