第8题
【其它】程序分析:阅读下面的程序,分析代码是否能编译通过,如果能编译通过,请列出运行的结果。如果不能编译通 过,请说明原因。 public class A { public static void main(String[] args) { System.out.println(Math.abs(-5)); System.out.println(Math.ceil(6.6)); System.out.println(Math.floor(-7.8)); System.out.println(Math.round(-4.9)); System.out.println(Math.max(8.1, -8.1)); System.out.println(Math.min(6.1, -6.1)); } }
点击查看答案
第9题
【其它】程序分析: 阅读下面的程序,分析代码是否能编译通过,如果能编译通过,请列出运行的结果。如果不能编译通 过,请说明原因。 public class A { public static void main(String[] args) { String s = "dfferghuklmbdfd"; System.out.println("str.length():" + s.length()); System.out.println("str.charAt(0):" + s.charAt(0)); System.out.println("lastIndexOf(m):" + s.lastIndexOf('m')); System.out.println("substring(2,4):" + s.substring(2, 4)); System.out.println("indexOf(g):" + s.indexOf('g')); } }
点击查看答案