SCJP 1.6版考題 092
出自 陳富國維基館
Given a correctly compiled class whose source code is:
1. package com.sun.sjcp;
2. public class Commander {
3. public static void main(String[] args) {
4. // more code here
5. }
6. }
Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/,
and that the classpath contains "." (current directory).
Which command line correctly runs Commander?
A. java Commander
B. java com.sun.sjcp.Commander
C. java com/sun/sjcp/Commander
D. java -cp com.sun.sjcp Commander
E. java -cp com/sun/sjcp Commander
解答
Ans: B
解說:
設類別檔放在/foo/com/sun/sjcp/中,目前目錄是/foo/,classpath為一個’.’, 那一個指令可以執行類別Commander? 程式碼中宣告Commander 是在套件com.sun.sjcp下, 執行即以java com.sun.sjcp.Commander來執行
| ||||||||||||||||||||