Java Reference
In-Depth Information
8. What is the output of the following program?
1. public class ScorePrinter {
2. public static void printScores(int... scores) {
3. for(int x : scores) {
4. System.out.print(x + “,”);
5. }
6. }
7.
8. public static void main(String [] args) {
9. int [] x = {198, 247, 152, 207};
10. printScores(x);
11. }
12.}
A. Compiler error on line 2
B. Compiler error on line 9
C. Compiler error on line 10
D. 198,247,152,207
E. 198,247,152,207,
9. Given the following class definition:
1. public class Test {
2. public void print(byte x) {
3. System.out.print(“byte”);
4. }
5. public void print(int x) {
6. System.out.print(“int”);
7. }
8. public void print(float x) {
9. System.out.print(“float”);
10. }
11. public void print(Object x) {
12. System.out.print(“Object”);
13. }
14.}
what is the result of the following statements?
20. Test t = new Test();
21. short s = 123;
22. t.print(s);
Search WWH ::




Custom Search