QUESTION 81
Given:
and two separate command line invocations:
java Yippee
java Yippee 1 2 3 4
What is the result?
A. No output is produced.
1 2 3
B. No output is produced.
2 3 4
C. No output is produced.
1 2 3 4
D. An exception is thrown at runtime.
1 2 3
E. An exception is thrown at runtime.
2 3 4
F. An exception is thrown at runtime.
1 2 3 4
Answer: ( B )
QUESTION 82
Given:
What is the result?
A. Compilation fails
B. An exception is thrown at runtime
C. doStuff x = 6 main x = 6
D. doStuff x = 5 main x = 5
E. doStuff x = 5 main x = 6
F. doStuff x = 6 main x = 5
Answer: ( D )
第10行参数x是值传递,不会改变main中x的值。
QUESTION 83
Given:
When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?
A. Line 5
B. Line 6
C. Line 7
D. Line 8
E. Line 9
F. Line 10
Answer: ( D )
栈内存用来存放基本类型的变量和对象的引用变量(对象的地址)
堆内存用来存放由new创建的对象和数组
QUESTION 84
Given:
What is the result?
A. Exception
B. A, B, Exception
C. Compilation fails because of an error in line 20.
D. Compilation fails because of an error in line 14.
E. A NullPointerException is thrown at runtime.
Answer: ( D )
改写的规定,子类抛出的异常要比父类的异常要小.本题中父类没有异常,子类也不能有异常.
QUESTION 85
Given:
What is the result?
A. harrier
B. shepherd
C. retriever
D. Compilation fails
E. retriever harrier
F. An exception is thrown at runtime.
Answer: ( D )
18行,case default: 语法错误,应改成default: