System.gc();
Runtime.gc();
System.freeMemory();
Runtime.getRuntime().growHeap();
Runtime.getRuntime().freeMemory();
第1题:
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?()
第2题:
11. public class Counter { 12. public static void main(String[] args) { 13. int numArgs = /* insert code here */; 14. } 15. } and the command line: java Counter one fred 42 Which code, inserted at line 13, captures the number of arguments passed into the program?()
第3题:
11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12?()
第4题:
11. String test = “Test A. Test B. Test C.”; 12. // insert code here 13. String[] result = test.split(regex); Which regular expression inserted at line 12 will correctly split test into “Test A,” “Test B,” and “Test C”?()
第5题:
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?()
第6题:
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 */ }
第7题:
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 */ }
第8题:
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();
第9题:
final
static
native
public
private
第10题:
Alpha a = x;
Foo f= (Delta)x;
Foo f= (Alpha)x;
Beta b = (Beta)(Alpha)x;
第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题:
System.gc();
Runtime.gc();
System.freeMemory();
Runtime.getRuntime().growHeap();
Runtime.getRuntime().freeMemory();
第13题:
现有: 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?()
第14题:
12. Date date = new Date(); 13. df.setLocale(Locale.ITALY); 14. String s = df.format(date); The variable df is an object of type DateFormat that has been initialized in line 11. What is the result if this code is run on December 14, 2000?()
第15题:
10. interface Foo {} 11. class Alpha implements Foo {} 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?()
第16题:
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?()
第17题:
Given 11.public interface Status { 12./* insert code here */ int MY_VALUE = 10; 13.} Which three are valid on line 12?()
第18题:
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 */ }
第19题:
Foo { public int bar() { return 1; } }
new Foo { public int bar() { return 1; } }
newFoo() { public int bar(){return 1; } }
new class Foo { public int bar() { return 1; } }
第20题:
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()));
第21题:
Point p = Line.getPoint();
Line.Point p = Line.getPoint();
Point p = (new Line()).getPoint();
Line.Point p = (new Line()).getPoint();
第22题:
b = nf.parse( input);
b = nf.format( input);
b = nf.equals( input);
b = nf.parseObject( input);
第23题:
System.gc();
Runtime.gc();
System.freeMemory();
Runtime.getRuntime().growHeap();
Runtime.getRuntime().freeMemory();
第24题:
final
static
native
public
private
abstract
protected