程序的输出结果是:Jepp好

解释原因:

  • 在循环中,变量i的值从1到4。
  • 当i为1时,执行case 1的代码,将c的值设为'J',然后输出c的值为J。
  • 接着执行case 2的代码,将c的值设为'e',然后输出c的值为e。
  • 当i为3时,执行case 3的代码,将c的值设为'p',然后输出c的值为p。
  • 当i为4时,执行default的代码,输出"好"。
  • 在循环结束后,程序输出结果为Jepp好。
阅读下面程序给出程序的输出结果并解释原因public class E 	public static void main String args 		char c = 0;		forint i=1;i=4;i++ 			switchi 			case 1 c = J;				Systemoutprintc;			case 2 c = e;				Systemoutprintc;				break;

原文地址: http://www.cveoy.top/t/topic/jdKV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录