What is the output of the following program? And explain why. public class Testing {       public static void main(String[] args) {          int a [] = { 0, 0, 0 };           update(a, a[2]);           try {   System.out.println(a[2]/a[1]); } catch(Exception e) { System.out.println("Exception!"); }   finally {  System.out.println("Finally!"); }       }       static int update(int x[], int y) {           for (int i = 1; i < x.length; i++)                if (y < x.length)  x[i] = x[i – 1] + 1;              return x[1];       } }-笔试面试资料

这是qklbishe.com第13117 篇笔试面试资料
提供答案分析,通过本文《What is the output of the following program? And explain why. public class Testing {       public static void main(String[] args) {          int a [] = { 0, 0, 0 };           update(a, a[2]);           try {   System.out.println(a[2]/a[1]); } catch(Exception e) { System.out.println("Exception!"); }   finally {  System.out.println("Finally!"); }       }       static int update(int x[], int y) {           for (int i = 1; i < x.length; i++)                if (y < x.length)  x[i] = x[i – 1] + 1;              return x[1];       } }-笔试面试资料》可以理解其中的代码原理,这是一篇很好的求职学习资料
本站提供程序员计算机面试经验学习,笔试经验,包括字节跳动/头条,腾讯,阿里,美团,滴滴出行,网易,百度,京东,小米,华为,微软等互联网大厂真题学习背诵。

答案:

What is the output of the following program? And explain why.

public class Testing {       public static void main(String[] args) {         	int a [] = { 0, 0, 0 };          	update(a, a[2]);          	try {   System.out.println(a[2]/a[1]); } catch(Exception e) { System.out.println("Exception!"); }		 		finally {  System.out.println("Finally!"); }       }       static int update(int x[], int y) {           for (int i = 1; i < x.length; i++)                if (y < x.length)  x[i] = x[i - 1] + 1;              return x[1];       } }

What is the output of the following program?    And     explain     why.   public class Testing {       public static void main(String[] args) {         	int a [] = { 0, 0, 0 };          	update(a, a[2]);          	try {   System.out.println(a[2]/a[1]); } catch(Exception e) { System.out.println(&quot;Exception!&quot;); }		 		finally {  System.out.println(&quot;Finally!&quot;); }       }       static int update(int x[], int y) {           for (int i = 1; i &lt; x.length; i++)                if (y &lt; x.length)  x[i] = x[i - 1] + 1;              return x[1];       } } jiayou11
首先调用update方法输出,返回值是1。然后下面0/0抛异常,输出catch内容,最后输出finally内容。
今天 17:37:28 回复(0)

文章部分来自互联网,侵权联系删除
www.qklbishe.com

区块链毕设网(www.qklbishe.com)全网最靠谱的原创区块链毕设代做网站
部分资料来自网络,侵权联系删除!
资源收费仅为搬运整理打赏费用,用户自愿支付 !
qklbishe.com区块链毕设代做网专注|以太坊fabric-计算机|java|毕业设计|代做平台 » What is the output of the following program? And explain why. public class Testing {       public static void main(String[] args) {          int a [] = { 0, 0, 0 };           update(a, a[2]);           try {   System.out.println(a[2]/a[1]); } catch(Exception e) { System.out.println("Exception!"); }   finally {  System.out.println("Finally!"); }       }       static int update(int x[], int y) {           for (int i = 1; i < x.length; i++)                if (y < x.length)  x[i] = x[i – 1] + 1;              return x[1];       } }-笔试面试资料

提供最优质的资源集合

立即查看 了解详情