编写代码完成两个变量的交换。 ___________; var apple1 = '青苹果'; var apple2 = '红苹果'; temp = apple1; ________________; apple2 = temp; console.log(apple1); // 输出结果:________ console.log(apple2); // 输出结果:________
举一反三
- 以下程序的运行结果为( )。class Apple { int n1 = 5; static int n2 = 0; void fun() { n1++; n2++; } } public class Main { public static void main(String[] args) { Apple apple1 = new Apple(); Apple apple2 = new Apple(); apple1.fun(); System.out.print(apple1.n1 + "," + apple1.n2 + ";"); apple2.fun(); apple2.fun(); System.out.print(apple2.n1 + "," + apple2.n2); } }
- 对于字符串和for循环的知识点,现设置代码如下:[img=413x259]17da6f9eb7df542.png[/img]请分析这段代码的输出结果为( )。 A: {'grape': '1',apple': '2','watermelon': '3','lemon': '4'} B: {grape:1,apple:2,watermelon:3,lemon:4} C: ['grape';'1', 'apple':12', 'watermelon';'3','lemon';'4'] D: [grape:1,apple:2,watermelon:3,lemon:4]
- 若有语句:chars1[]="apple1",s2[8],*s3,*s4="apple2";则对库函数strcpy错误调用的是______ A: strcpy(s1,"apple2"); B: strcpy(s4,"apple1"); C: strcpy(s3,"apple1"); D: strcpy("apple2",s2);
- 下面创建数组的方法正确的有( )。 A: var fruit=new Array("apple","banana","orange","peach"); B: var fruit={"apple","banana","orange","peach"}; C: var fruit=["apple","banana","orange","peach"]; D: var fruit=["apple","banana","orange",123];
- 若有语句:int *apple,a=4;和apple=&a;下面均代表地址的一组选项是______ A: a,apple,*&a B: &*a,&a,*apple C: *&apple,*apple,&a D: &a,&*apple,apple