资源描述
1. Which of the following statements about JAVA language is correct?
A. Constructor within class can not be ignored
B. Constructor must have the same name with class, but method can’t
C. Constructor can only be executed when creating a new object
D. One class can only define one constructor
2. For JAVA language, which one Operator is VALID?
A. &
B. <>
C. @
D. :=
3. Please chose the right statement about the following JAVA program
class Cat {
public void cry() {
System.out.print("miaow ");
}
}
class DummyCat extends Cat {
public void cry() {
}
}
public class CatCry {
public static void main(String args[]) {
Cat mimi = new Cat();
Cat dummy = new DummyCat();
mimi.cry();
dummy.cry();
}
}
A. It can not be compiled correctly
B. It will print nothing
C. It will print “miaow”
D. It will print “miaow miaow ”
4. Please figure out the correct output of the following JAVA program
public static void main(String[] a){
String s = "Good";
System.out.print( "Good"+"bye"=="Go"+"odbye" );
System.out.print( (s+"bye").intern()=="Go"+"odbye" );
}
A. falsefalse
B. falsetrue
C. truefalse
D. truetrue
5. After executing the following code:
a=0;c=0;
do{
--c;
a=a--;
} while (a>=0);
what is c’s value?
A. 0
B. -1
C. -2
D. Dead Loop
6. Which statement is CORRECT?
A. The keyword abstract can be used for field, method and class
B. Body part of abstract method must be embraced by using “{ }”
C. “{ }” may be used or not when declaring abstract method
D. “{ }” can NOT be used when declaring abstract method
7. Which statement is INCORRECT
A. List will save the elements in specific order.
B. There may be duplicate elements within List.
C. There may be duplicate elements within Set.
D. Map will save key-value pair.
8. If run the following JAVA application, the output should be:
public class Test1 {
public static void changeStr(String str){
str=”welcome”;
}
public static void main(String[] args) {
String str=”1234”;
changeStr(str);
System.out.println(str);
}
}
A. 1234
B. welcome
C. 1234welcome
D. An exception is thrown at runtime.
9. If run the following JAVA application, the output should be:
Public class Test2 {
static boolean foo(char c) {
System.out.print(c);
return true;
}
public static void main(String[] argv) {
int i = 0;
for (foo('A'); foo('B') && (i < 2); foo('C')) {
i++;
foo('D');
}
}
}
A. ABDCBDCB
B. ABCDABCD
C. ABCDBDCB
D. An exception is thrown at runtime.
10. Please write some code to implement binary search algorithm(二分查找算法) in JAVA language.
public static int binarySearch(int[] a, int value) // search “value” in sorted array “a” by binary search algorithm, and return the index of the first match. Please take the search failure case into account.
11. How do you indicate where a component will be positioned using Flowlayout?
A. North, South, East, West
B. Assign a row/column grid reference
C. Pass a X/Y percentage parameter to the add method
D. Do nothing, the FlowLayout will position the component
12. For factory pattern, which one of below is INCORRECT:
A. Factory pattern reduces the coupling or the dependencies between the calling code and called objects
B. We can not use the singleton pattern within our factory pattern code
C. The factory design pattern instantiates a class in a more flexible way than directly calling the constructor
D. Abstract Factory classes are often implemented with Factory Methods, but they can also be implemented using Prototype
13. What does “open-closed” OOD principle mean:
A. open for modifications, closed for extension
B. open for extension, closed for modifications
C. open for inheritance, closed for extension
D. open for extension, closed to inheritance
14. “Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it”
Which OOD principle is the above description:
A. SRP (Single Responsibility Principle)
B. LSP (Liskov Substitution Principle )
C. ISP (Interface Segregation Principle)
D. OCP (Open-Closed Principle)
15. “Only communicate with your direct friends”
“Do not speak with foreigners”
For which OOD principle is the above popular description?
A. DIP (Dependency Inversion Principle)
B. LKP (Least Knowledge Principle)
C. ISP (Interface Segregation Principle)
D. OCP (Open-Closed Principle)
16. For Decorator pattern and Proxy pattern, which one of below is wrong:
A. Proxy provides the same interface. Decorator provides an enhanced interface.
B. Both of them describe how to provide a level of indirection to another object
C. Both of their implementations keep a reference to the object to which they forward requests
D. Both of them support recursive composition
17. For Mediator pattern and Facade pattern, which one of below is WRONG:
A. Both of them abstract functionality of existing classes.
B. Same as Mediator, Facade defines a multidirectional protocol where it makes requests of the subsystem classes and vice versa
C. Mediator is known/referenced by the colleague objects, whereas Facade is not known by the subsystem classes
D. Facade defines a simpler interface to a subsystem, it doesn't add new functionality, while Mediator routinely "adds value",
18. Which design pattern is described by above picture:
A. Chain of Responsibility
B. Command
C. Mediator
D. Adapter
19. Suppose we use prototype pattern to create new objects from the existing objects, if the value of the new object is changed, then the value of the original existing object:
A. Will not be changed
B. Will be changed
C. Will be partially changed
D. Sometime will be changed, and sometime not
20. Which of following represents the relationship between system and user?
A. Class diagram
B. User case
C. Attribute.
D. Status diagram.
展开阅读全文