Exhibit :
1. public class test (
2. private static int j = 0;
3.
4. private static boolean methodB(int k) (
5. j += k;
6. return true;
6. )
7.
8. public static void methodA(int i) {
9. boolean b:
10. b = i < 10 | methodB (4);
11. b = i < 10 || methodB (8);
12. }
13.
14. public static void main (String args[] ) (
15. methodA (0);
16. system.out.printIn(j);
17. )
18. )
What is the result?
A. The program prints “0”
B. The program prints “4”
C. The program prints “8”
D. The program prints “12”
E. The code does not complete.
答案: B
为什么是B我觉的是D
b=i<10|methodB(4)
是两边都要执行的
b=i<10||methodB(8)
这个虽然是短路运算符但,0<10是true,还是要计算methodB(8)的
那为什么是B??
Which two demonstrate an “is a” relationship? (Choose Two)
A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Shape { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal (private Species species;)
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
)
答案: D, E
为什么
雇员是人类,但人类不全是雇员我觉的是对的,为什么呢??谢谢了
1. public class test (
2. private static int j = 0;
3.
4. private static boolean methodB(int k) (
5. j += k;
6. return true;
6. )
7.
8. public static void methodA(int i) {
9. boolean b:
10. b = i < 10 | methodB (4);
11. b = i < 10 || methodB (8);
12. }
13.
14. public static void main (String args[] ) (
15. methodA (0);
16. system.out.printIn(j);
17. )
18. )
What is the result?
A. The program prints “0”
B. The program prints “4”
C. The program prints “8”
D. The program prints “12”
E. The code does not complete.
答案: B
为什么是B我觉的是D
b=i<10|methodB(4)
是两边都要执行的
b=i<10||methodB(8)
这个虽然是短路运算符但,0<10是true,还是要计算methodB(8)的
那为什么是B??
Which two demonstrate an “is a” relationship? (Choose Two)
A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Shape { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal (private Species species;)
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
)
答案: D, E
为什么
雇员是人类,但人类不全是雇员我觉的是对的,为什么呢??谢谢了
public static void methodA(int i) {
boolean b:
b = i < 10 | methodB (4);
b = i < 10 || methodB (8);
}
i 为零时 b = i < 10 | methodB (4); 两边都要执行,执行完后 j=4;
接着 b = i < 10 || methodB (8); 因为 i<10为真,且是短路运算,所以methodB(8)不会再执行。第二题前三个选项java語法都有问题,E显然是IS A关系,而D个人觉得是HAS A关系.
如 5>3 | 2/0 > 1 会跑出异常 而 5>3 || 2/0 > 1 可以正常执行表达式结果为true
第二题的D是不是public class Animal extends Species{}?上面的语法看不懂。
第二题 abc语法错误,应该implements
E是is-a关系,但D好像是has-a关系吧