Which command line correctly runs Commander?

Given a correctly compiled class whose source code is:

1. package com.sun.sjcp;
2.
3. public class Commander {
4. public static void main(String[] args) {
5. // more code here
6. }
7. }

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?

Given a correctly compiled class whose source code is:

1. package com.sun.sjcp;
2.
3. public class Commander {
4. public static void main(String[] args) {
5. // more code here
6. }
7. }

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

Explanation:



Leave a Reply 1

Your email address will not be published. Required fields are marked *