Progress Test 2 - Key Spring20
Progress Test 2 - Key Spring20
System.out.println(side);
}
}
void showSide() {
System.out.println(side/10);
[3] sh.showSide();
}
}
a. 100
b. 10
c. can not access the private method at row [3]
d. syntax error at row [2]
import java.util.*;
list.add("jQuery");
list.add("is");
list.add("a");
list.add("JavaScript");
list.add("Library");
Collections.sort(list);
System.out.println(list);
a. Compile-time error
b. 12
c. 21
d. Unpredictable output
6. Which option of the following statements about input byte streams is false
a. A low-level input stream returns bytes to its caller
b. A high-level filter input stream returns general-format data to its caller
c. A high-level filter input stream reads bytes from a low-level input stream, or
from another filter input stream
d. A low-level input stream reads bytes from a high-level input stream
a. Runtime error
b. The source code is no problem
c. Compile-time error: class Circle can’t imlement both interface IShape1, IShape2
d. Compile-time error: class Circle does not override abstract method f2
11. All of the numeric wrapper classes are subclasses of the class ________?
a. Integer
b. Number
c. Wrapper
d. String
12. A wrapper class encapsulates a single ......... value.
}
public static <T extends Number> double add(T num1, T num2){
return num1.doubleValue() + num2.doubleValue();
}
}
a. Compile-time error
b. Runtime error
c. 16
d. All of the others
String title;
public Story (String s1, String s2){
title=s1.concat(s2);
}
public String toString() {
return title.toUpperCase();
}
public static void main(String[] args) {
String s=new String("Humpty Dumpty sat on a wall");
String [] arr=s.split("[, ,?,.]");
Story obj=new Story(arr[0],arr[1]);
System.out.println(obj.toString());
}
}
a. hUMPTYdUMPTY
b. HUMPTYDUMPTY
c. humpty dumpty
d. Humpty Dumpty
class AA {
int i;
int j;
AA() {
i = 1;
j = 2;
System.out.print(obj1.equals(obj2));
System.out.print(obj1 == obj2);
}
}
a. falsetrue
b. truefalse
c. falsefalse
d. truetrue
19. __(1)__ is used to postpone the handling of a checked exception and __(2)__ is
used to invoke an exception explicitly.
postpone the handling: dừng xử lý = cho qua ngoại lệ throws = khai báo ngoại lệ
(declare)
to invoke an exception explicitly: = throw đối tượng ngoại lệ
so sánh từ khóa throws declare exception, throw exception
20. Which of these methods sets every element of a List to a specified object?
a. set()
b. fill()
c. complete()
d. add()