System.gc();
Runtime.gc();
System.freeMemory();
Runtime.getRuntime().growHeap();
Runtime.getRuntime().freeMemory();
第1题:
11. List list = // more code here 12. Collections.sort(list, new MyComparator()); Which code will sort this list in the opposite order of the sort in line 12?()
第2题:
现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?()
第3题:
11. rbo = new ReallyBigObject(); 12. // more code here 13. rbo = null; 14. /* insert code here */ Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the object rbo?()
第4题:
Which three will compile and run without exception?()
第5题:
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
int foo() { /* more code here */ }
void foo() { /* more code here */ }
第6题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第7题:
Point p = new Point();
Line.Point p = new Line.Point();
The Point class cannot be instatiated at line 15.
Line 1 = new Line() ; 1.Point p = new 1.Point();
第8题:
final
static
native
public
private
第9题:
private synchronized Object o;
void go(){ synchronized(){/* code here */}
public synchronized void go(){/* code here */}
private synchronized(this) void go(){/* code here */}
void go(){ synchronized(Object.class){/* code here */}
void go(){ Object o = new Object(); synchronized(o){/* code here */}
第10题:
The application will crash.
The code on line 29 will be executed.
The code on line 5 of class A will execute.
The code on line 5 of class B will execute.
The exception will be propagated back to line 27.
第11题:
Foo.beta() is a valid invocation of beta().
Foo.alpha() is a valid invocation of alpha().
Method beta() can directly call method alpha().
Method alpha() can directly call method beta().
第12题:
final
static
native
public
private
abstract
protected
第13题:
10. class Line { 11. public static class Point { } 12. } 13. 14. class Triangle { 15. // insert code here 16. } Which code, inserted at line 15, creates an instance of the Point class defined in Line?()
第14题:
public class Team extends java.util.LinkedList { public void addPlayer(Player p) { add(p); } public void compete(Team opponent) { /* more code here */ } } class Player { /* more code here */ } Which two are true?()
第15题:
10. class Line { 11. public class Point { public int x,y; } 12. public Point getPoint() { return new Point(); } 13. } 14. class Triangle { 15. public Triangle() { 16. // insert code here 17. } 18. } Which code, inserted at line 16, correctly retrieves a local instance of a Point object?()
第16题:
Given 11.public interface Status { 12./* insert code here */ int MY_VALUE = 10; 13.} Which three are valid on line 12?()
第17题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第18题:
This code will compile.
This code demonstrates proper design of an is-a relationship.
This code demonstrates proper design of a has-a relationship.
A Java programmer using the Team class could remove Player objects from a Team object.
第19题:
Collections.reverseSort(list, new MyComparator());
Collections.sort(list, new MyComparator()); list.reverse();
Collections.sort(list, new InverseComparator( new MyComparator()));
Collections.sort(list, Collections.reverseOrder( new MyComparator()));
第20题:
Point p = Line.getPoint();
Line.Point p = Line.getPoint();
Point p = (new Line()).getPoint();
Line.Point p = (new Line()).getPoint();
第21题:
public int compareTo(Object o) {/*mode code here*/}
public int compareTo(Score other) {/*more code here*/}
public int compare(Score s1,Score s2){/*more code here*/}
public int compare(Object o1,Object o2){/*more code here*/}
第22题:
只在第11行
在第8行和第11行
在第5行、第8行和第11行
在第2行、第5行、第8行和第11行
第23题:
System.gc();
Runtime.gc();
System.freeMemory();
Runtime.getRuntime().growHeap();
Runtime.getRuntime().freeMemory();