笔试题 Java 易错题精选 1.写出下列程序的运行结果( )String 不变性Java 值传递 public class Test { public static void main(String[] args) { String a = "hello"; change(a); System.out.println(a); } public static void change(String name) { name = "world"; } } 运行结果 he
三角形 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 156024 Accepted Submission(s): 50080 Problem Description 给定三条边,请你判断一下能不能组成一个三角形. Input 输入数据第一行包含一个数M,接下有M行,每行一个实例,包含三个正数A,B,C.其中A,B,C <1
1.温度转换 t=input() if t[-1]=="J": t=int(t[:-1]) t1=t/4.186 print("%.3fcal"%t1) else: t=int(t[0:-3]) t2=t*4.186 print("%.3fcal"%t2) #这一题不难,但要注意input()里面不要加提示语句,会报错的. 2.快乐的数字 n=input() h=0 i=0 while i<100: for x in n: h+=int(x
JAVA程序改错 1. abstract class Name { private String name; public abstract boolean isStupidName(String name) { } } 答案: 错.abstract method必须以分号结尾,且不带花括号. 2. public class Something { void doSomething () { private String s = ""; int l = s.length(); } }
class A{ public static String s="A.s"; } class B extends A{ public static String s="B.s"; public static void main(){ A a= new B(); B b= new B(); A c = new B(); A d = new B(); System.out.println("a.s:"+a.s); //由A类调用静态方法 System
li = [] for x in range(10): print(x) //在函数没有执行前(li[0]()),for 循环中x已经执行完,x会一直为 9 def fun(): print(x) //一直为 9 ,fun函数在for循环中是没有被调用的 return x li.append(fun) print(li[0]()) //9 li = [lambda :x for x in range(10)] print(type(li)) #<class 'list'> print(type